https://www.lanqiao.cn/courses/31016/learning/?id=1896464&compatibility=false
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PII;
typedef vector<long long> VI;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define pb(i) push_back(i)
#define int long long
#define INF 0x3f3f3f3f
#define oz 998244353
#define endl '\n'
#define N 200010
const int mod = 1e9 + 7;
int p[N], si[N];
int find(int x) {
if (x != p[x]) p[x] = find(p[x]);
return p[x];
}
//size[find(b)] += size[find(a)];
//p[find(a)] = find(b);
int a, b;
int res;
string s;
int n = s.size();
void dfs(int u, int x) {
if (u < (int)s.size()) {
int num = s[u] - '0';
int t = min(9 - num, a); //+操作最大化
a -= t;
dfs(u + 1, x * 10 + num + t);
a += t;
if (b > num) { // 减操作做大化
b -= num + 1;
dfs(u + 1, x * 10 + 9);
b += num + 1;
}
} else {
res = max(res, x);
}
}
void solve() {
cin >> s >> a >> b;
// cout << s << endl;
// dfs(1, 1, to_string(n));
dfs(0, 0);
cout << res << endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T = 1;
// cin >> T;
while (T --)
solve();
return 0;
}