#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a % b != 0) return gcd(b, a % b);
  return b;
}
int main() {
  int n, x = 0, y = 0;
  cin >> n;
  string a, b;
  cin >> a >> b;
  int k = a.size() * b.size() / gcd(a.size(), b.size());
  for (int i = 0; i < k; i++) {
    int t1 = i % a.size(), t2 = i % b.size();
    if (a[t1] != b[t2]) {
      if ((a[t1] > b[t2] && a[t1] - b[t2] != 3) || b[t2] - a[t1] == 3)
        x++;
      else
        y++;
    }
  }
  x *= n / k;
  y *= n / k;
  n %= k;
  for (int i = 0; i < n; i++) {
    int t1 = i % a.size(), t2 = i % b.size();
    if (a[t1] != b[t2]) {
      if ((a[t1] > b[t2] && a[t1] - b[t2] != 3) || b[t2] - a[t1] == 3)
        x++;
      else
        y++;
    }
  }
  cout << x << ' ' << y;
}
