#include using namespace std; string A,B; vector> memo; int opt(int i, int j) { if (i == A.size()) return B.size()-j; if (j == B.size()) return A.size()-i; if (memo[i][j] != -1) return memo[i][j]; if (A[i] == B[j] || A[i] == '*' || B[j] == '*') return memo[i][j] = opt(i+1, j+1); return memo[i][j] = min(opt(i, j+1)+1, opt(i+1, j)+1); } int main() { string a, b; cin >> a >> b; int ans = 0; for (char c : a) { if ('0' <=c && c <= '9') {ans++;A += string(c-'0', '*');} else A += c; } for (char c : b) { if ('0' <=c && c <= '9') {ans++;B += string(c-'0', '*');} else B += c; } memo = vector>(A.size(), vector(B.size(), -1)); cout << ans+opt(0, 0) << endl; }