#include #define sz(x) (int)x.size() #define pb push_back #define FOR(i, n) for(int i = 0; i < (n); ++i) using namespace std; string a, b, c , d; int ile; int ans = 0; void parse(){ for(auto&u:c){ if(u>='0' && u <='9'){ ile += u-'0'; ans++; } else{ a.pb(u); } } for(auto&u:d){ if(u>='0' && u <='9'){ ile += u-'0'; ans++; } else{ b.pb(u); } } } int dp[10001][1001]; int lcs(){ for(int i = 1; i <= sz(a); i++){ for(int j = 1; j <= sz(b); j++){ if(a[i-1] == b[j-1]){ dp[i][j] = dp[i-1][j-1] +1; } else{ dp[i][j] = max(dp[i][j-1], dp[i-1][j]); } } } return dp[sz(a)][sz(b)]; } signed main(){ ios::sync_with_stdio(0); cin.tie(0); cin >> c >> d; parse(); //cout << a << " " << b << endl; int potrz = sz(a) + sz(b) - 2*lcs(); //cout << ile << ' ' << potrz << endl; if(potrz <= ile){ ile -= potrz; if(ile&1){ ans++; } } else{ potrz -= ile; ans += potrz; } cout << ans << '\n'; return 0; }