#include <bits/stdc++.h>
using namespace std;
const int NMAX = 200000;
const double EPS = 1e-9;
int n;
int d[2000][2000];
string a, b;
char buf[2000];
bool win(char a, char b) {
  if (a == 'R' && b == 'S') return true;
  if (a == 'S' && b == 'P') return true;
  if (a == 'P' && b == 'R') return true;
  return false;
}
int main() {
  scanf("%d\n", &n);
  gets(buf);
  a = buf;
  gets(buf);
  b = buf;
  memset(d, -1, sizeof d);
  int i = 0, j = 0, cnt1 = 0, cnt2 = 0, h = 0;
  for (; h < n && d[i][j] == -1; h++) {
    d[i][j] = 1;
    if (win(a[i], b[j])) cnt1++;
    if (win(b[j], a[i])) cnt2++;
    i = (i + 1) % (int)(a).size();
    j = (j + 1) % (int)(b).size();
  }
  if (h < n) {
    int mul = n / h;
    cnt1 *= mul;
    cnt2 *= mul;
    for (int k = 0; k < int(n % h); k++) {
      if (win(a[i], b[j])) cnt1++;
      if (win(b[j], a[i])) cnt2++;
      i = (i + 1) % (int)(a).size();
      j = (j + 1) % (int)(b).size();
    }
  }
  cout << cnt2 << " " << cnt1 << endl;
  return 0;
}
