func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAX_N = 1000000;   struct UnionFind {     int par[MAX_N], ra[MAX_N];     void init(int n) {       for (int(i) = 0; (i) < (n); (i)++) par[i] = i, ra[i] = 0;     }     int find(int x) { return par[x] == x ? x : par[x] = find(par[x]); }     bool same(int x, int y) { return find(x) == find(y); }     void unite(int x, int y) {       if ((x = find(x)) != (y = find(y))) {         if (ra[x] < ra[y]) swap(x, y);         par[y] = x, ra[x] += (ra[x] == ra[y]);       }     }   };   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long A, B;   string a, b;   int pp[1000000][26];   int sz[1000000];   UnionFind uf;   int main() {     scanf( %I64d%I64d , &A, &B);     cin >> a >> b;     long long al = a.size(), bl = b.size();     long long st = al * bl;     st /= gcd(al, bl);     uf.init(al);     for (int(i) = 0; (i) < (al); (i)++) uf.unite(i, (i + bl) % al);     for (int(i) = 0; (i) < (al); (i)++) {       int ns = uf.find(i);       pp[ns][a[i] -  a ]++;       sz[ns]++;     }     long long ans = 0;     for (int(i) = 0; (i) < (bl); (i)++) {       int ns = uf.find(i % al);       for (int(j) = 0; (j) < (26); (j)++)         if (j != b[i] -  a ) ans += pp[ns][j];     }     long long kkd = A * al / st;     cout << ans * kkd << endl;   }   