#include<bits/stdc++.h> #define ll long long usingnamespace std;
constint N = 1e6 + 66;
int n, k, top; int a[N], sta[N], vis[N]; char ch[N];
signedmain() { int i; scanf ("%s", ch + 1), k = read(), n = strlen(ch + 1); if (n == k) {puts("0"); return0;} for (i = 1; i <= n; ++ i) a[i] = ch[i] - '0', vis[i] = 1;
sta[++ top] = 1; for (i = 2; i <= n; ++ i) { if (a[i] > a[sta[top]]) sta[++ top] = i; else { while (a[i] < a[sta[top]]) { vis[sta[top]] = 0, top --; if (! (-- k)) break; } sta[++ top] = i; } if (k == 0) break; } if (k) for (i = n; i >= 1; -- i) if (vis[i]) {vis[i] = 0; if (! (-- k)) break;} memset(a, 0, sizeof a), top = 0; for (i = 1; i <= n; ++ i) if (vis[i]) a[++ top] = ch[i] - '0'; int now = 1; while (a[now] == 0 && now < top) ++ now; for (i = now; i <= top; ++ i) cout << a[i]; puts("");