#include #include #include #include using namespace std; vector OOO[4][4]; int cnt[4][4]; int main(){ string s, t; cin >> s >> t; unordered_map ump; ump['A'] = 0; ump['C'] = 1; // (1, 3, 0) ump['G'] = 2; ump['T'] = 3; int n = s.size(); int m = t.size(); for(int i = 0; i < n; i++){ if(s[i] != t[i]){ OOO[ump[s[i]]][ump[t[i]]].push_back(i); cnt[ump[s[i]]][ump[t[i]]]++; } } for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ if(i == j) continue; reverse(OOO[i][j].begin(),OOO[i][j].end()); } } int c1 = 0; for(int i = 0; i < n; i++){ if(s[i] != t[i]){ if(OOO[ump[t[i]]][ump[s[i]]].size() && OOO[ump[s[i]]][ump[t[i]]].size()){ int x = OOO[ump[t[i]]][ump[s[i]]].back(); OOO[ump[t[i]]][ump[s[i]]].pop_back(); OOO[ump[s[i]]][ump[t[i]]].pop_back(); cnt[ump[s[i]]][ump[t[i]]]--; cnt[ump[t[i]]][ump[s[i]]]--; c1++; swap(s[i], s[x]); } } } for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ //cout << cnt[i][j] << " "; } //cout << endl; } int res = c1; for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ if(i == j) continue; for(int k = 0; k < 4; k++){ if(j == k) continue; int mn = min({cnt[i][j], cnt[j][k], cnt[k][i]}); if(i == 1 && j == 3 && k == 0){ //cout << cnt[i][j] << " " << cnt[j][k] << " " << cnt[k][i] << endl; } if(mn > 0){ //cout << mn << endl; res += mn * 2; cnt[i][j] -= mn; cnt[j][k] -= mn; cnt[k][i] -= mn; } } } } for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ //cout << cnt[i][j] << " "; } //cout << endl; } for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ if(i == j) continue; for(int k = 0; k < 4; k++){ if(j == k) continue; for(int l = 0; l < 4; l++){ if(k == l) continue; int mn = min({cnt[i][j], cnt[j][k], cnt[k][l], cnt[l][i]}); if(mn > 0){ res += mn * 3; cnt[i][j] -= mn; cnt[j][k] -= mn; cnt[k][l] -= mn; cnt[l][i] -= mn; } } } } } cout << res << endl; //cout << s << " " << t << " " << c2 << endl; //cout << c1 + (2 * c2 / 3) + (c2 % 3) << endl; }