#include <bits/stdc++.h>
using namespace std;
int num[1100000][26];
char a[1100000], b[1100000];
bool vst[1100000];
int v[1100000];
int main() {
  long long n, m;
  while (scanf("%I64d %I64d", &n, &m) != EOF) {
    scanf(" %s %s", a, b);
    int cnt = 0;
    int la = strlen(a);
    int lb = strlen(b);
    memset(vst, false, sizeof(vst));
    v[cnt++] = 0;
    vst[0] = true;
    int pos = 0;
    while (true) {
      pos = (pos + lb) % la;
      if (vst[pos]) break;
      v[cnt++] = pos;
      vst[pos] = true;
    }
    sort(v, v + cnt);
    int X;
    if (cnt == 1)
      X = la;
    else
      X = v[1] - v[0];
    for (int i = 0; i < X; i++) {
      memset(num[i], 0, sizeof(num[i]));
      for (int j = 0; j < cnt; j++) num[i][a[v[j] + i] - 'a']++;
    }
    long long ans = 0;
    int x = 0;
    for (int i = 0; i < lb; i++) {
      long long tmp = 0;
      for (int j = 0; j < 26; j++)
        if (j != b[i] - 'a') tmp += num[x][j];
      ans += tmp * (long long)(m / cnt);
      x = (x + 1) % X;
    }
    cout << ans << endl;
  }
}
