#include using namespace std; using ll = long long; using Vi = vector; using Pii = pair; #define mp make_pair #define pb push_back #define x first #define y second #define rep(i,b,e) for(int i = (b); i < (e); i++) #define each(a, x) for(auto& a : (x)) #define all(x) (x).begin(),(x).end() #define sz(x) int((x).size()) #define tem template #define pri(x,y)tem auto operator<<(t& o, u a)->decltype(x,o) { o << y; return o; } pri(a.print(), "{"; a.print(); "}"); pri(a.y, "(" << a.x << ", " << a.y << ")"); pri(all(a), "["; auto d=""; for (auto i : a) (o << d << i, d = ", "); o << "]"); void DD(...) {} tem void DD(t s, u a, w... k) { for (int b = 44; *s && *s - b; cerr << *s++) b += ((*s == 41) - (*s == 40)) * 88; cerr << ": " << a << *s++; DD(s, k...); } tem vector span(const t* a, u n) { return {a, a+n}; } #ifdef LOC #define deb(...) (DD("[,\b :] "#__VA_ARGS__, __LINE__, __VA_ARGS__), cerr << endl) #else #define deb(...) #endif #define DBP(...) void print() { DD(#__VA_ARGS__, __VA_ARGS__); } int mat[4][4]; int get(char c) { if (c == 'A') return 0; if (c == 'C') return 1; if (c == 'G') return 2; return 3; } int main() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(12); string s, t; cin >> s >> t; int n = sz(s); ll ans = 0; rep(i, 0, n) { int a = get(s[i]), b = get(t[i]); mat[a][b]++; } rep(len, 1, 5) { Vi perm(4); iota(all(perm), 0); do { int sm = INT_MAX; rep(i, 0, len) { sm = min(sm, mat[perm[i]][perm[(i+1)%len]]); } ans += sm*ll(len-1); rep(i, 0, len) { mat[perm[i]][perm[(i+1)%len]] -= sm; } } while (next_permutation(all(perm))); } cout << ans << endl; return 0; }