#include #include #include using namespace std; typedef vector> graph; struct edge { int a, b; }; typedef vector path; int lettr_code(char c) { switch(c) { case 'A': return 0; case 'C': return 1; case 'T': return 2; case 'G': return 3; } } bool check_path(const graph& g, const path& p) { for (edge e : p) { if (g[e.a][e.b] == 0) return false; } return true; } void rm_path(graph& g, const path& p) { for (edge e : p) { g[e.a][e.b]--; } } int main() { ios_base::sync_with_stdio(0); string a, b; cin >> a >> b; int n = a.size(); graph g(4, vector(4, 0)); for (int i = 0; i < n; i++) { if (a[i] == b[i]) continue; g[lettr_code(a[i])][lettr_code(b[i])]++; } vector paths; vector cycle(4); cycle[0] = 0; cycle[1] = 1; cycle[2] = 2; cycle[3] = 3; do { for (int i = 2; i <= 4; i++) { path p; for (int j = 0; j < i-1; j++) { p.push_back({ cycle[j], cycle[j+1] }); } p.push_back({ cycle[i-1], cycle[0] }); paths.push_back(p); } } while (next_permutation(cycle.begin(), cycle.end())); int swaps = 0; for (path& p : paths) { while (check_path(g, p)) { rm_path(g, p); swaps += p.size() - 1; } } cout << swaps << endl; return 0; }