#include using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair pii; typedef vector vi; bool ok(const string& a, const string& b) { rep(i,0,sz(a)) { if (a[i] - '0' + b[i] - '0' > 9) return false; } return true; } void neg(string& x) { x[0]--; rep(i,0,sz(x)) { if (x[i] < '0') { x[i] = '9'; x[i+1]--; } } } void add(string& x) { x[0]++; rep(i,0,sz(x)) { if (x[i] > '9') { x[i] = '0'; x[i+1]++; } } } string solve(string a, string b) { string res(sz(a), '0'); while (!ok(a, b)) { neg(a); add(b); add(res); } return res; } int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); string a, b; cin >> a >> b; reverse(all(a)); reverse(all(b)); while (sz(a) < sz(b)) a.push_back('0'); while (sz(a) > sz(b)) b.push_back('0'); // In case of carry. a.push_back('0'); b.push_back('0'); string r1 = solve(a, b); string r2 = solve(b, a); reverse(all(r1)); reverse(all(r2)); string res = min(r1, r2); reverse(all(res)); while (sz(res) > 1 && res.back() == '0') res.pop_back(); reverse(all(res)); cout << res << endl; }