#include <bits/stdc++.h>
char a[1005], b[1005];
int alen, blen, cnt1, cnt2;
int gcd(int a, int b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
void work(int t) {
  int i;
  for (i = 0; i < t; i++) switch (a[i % alen] - b[i % blen]) {
      case 1:
        cnt1++;
        break;
      case 2:
        cnt1++;
        break;
      case 3:
        cnt2++;
        break;
      case -1:
        cnt2++;
        break;
      case -2:
        cnt2++;
        break;
      case -3:
        cnt1++;
        break;
    }
}
int main() {
  int i, n, t, s;
  while (~scanf("%d", &n)) {
    cnt1 = 0, cnt2 = 0;
    scanf("%s%s", a, b);
    alen = strlen(a);
    blen = strlen(b);
    t = lcm(alen, blen);
    work(t);
    s = n / t;
    cnt1 *= s;
    cnt2 *= s;
    work(n % t);
    printf("%d %d\n", cnt1, cnt2);
  }
  return 0;
}
