public class Practice03 {
public static void main(String[] args) throws UnsupportedEncodingException {
// 获取字符串和字节个数
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
int n = sc.nextInt();
// 先将字符串转换为字节数组
byte[] bs = str.getBytes("gbk");
// 判断要截取的字节个数是否合法
if (n <0 || n > bs.length){
return;
}
// 按照指定的字节个数进行截取
String sub = new String(bs,0,n,"gbk");
// 判断是否截取了半个字符
int index = sub.length() - 1;
if (sub.charAt(index) != str.charAt(index)){
sub = new String(bs,0,n - 1,"gbk");
}
System.out.println(sub);
}
}