package huawei.jishi;
import java.util.Scanner;
public class DivideString {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
String str = scanner.next();
int num = scanner.nextInt();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) >= 48 && str.charAt(i) <= 57) {
} else {
// 去掉数字,题目傻逼就傻逼在这,我是截取之后才去除数字的,结果通过60%
sb.append(str.charAt(i));
}
}
// 去掉数字用正则
// String string2 = str.replaceAll("\\d","");
String string = divideStringByByte(sb.toString(), num);
System.out.println(string);
}
}
private static String divideStringByByte(String str, int num) throws Exception {
// TODO Auto-generated method stub
// 无效输入
if (str == null || str.length() < 1 || num < 1) {
return "";
}
// 按照GBK编码
int count = 0;// 中文的个数
byte[] bs = str.getBytes("GBK");
int len = bs.length;
if (num < len) {
for (int i = 0; i < num; i++) {
if (bs[i] < 0) {
count++;
}
}
if (count % 2 == 0) {
return new String(bs, 0, num, "GBK");
} else {
return new String(bs, 0, num - 1, "GBK");
}
} else {
return str;
}
}
}