#include <bits/stdc++.h>
using namespace std;
int f(char c1, char c2) {
  if (c1 == 'R' && c2 == 'S') return 1;
  if (c1 == 'S' && c2 == 'P') return 1;
  if (c1 == 'P' && c2 == 'R') return 1;
  if (c2 == 'R' && c1 == 'S') return -1;
  if (c2 == 'S' && c1 == 'P') return -1;
  if (c2 == 'P' && c1 == 'R') return -1;
  return 0;
}
int main() {
  int n, j1 = 0, j2 = 0, i, r1 = 0, r2 = 0, t;
  char s1[1500], s2[1500];
  cin >> n >> s1 >> s2;
  for (i = 0; i < n; ++i) {
    t = f(s1[j1], s2[j2]);
    if (t == 1) ++r2;
    if (t == -1) ++r1;
    ++j1;
    if (!s1[j1]) j1 = 0;
    ++j2;
    if (!s2[j2]) j2 = 0;
    if (j1 == 0 && j2 == 0) {
      r1 *= n / (i + 1);
      r2 *= n / (i + 1);
      n %= (i + 1);
      i = -1;
    }
  }
  cout << r1 << " " << r2;
  return 0;
}
