#include <bits/stdc++.h>
using namespace std;
int n, i, j, la, lb, sa, sb, k, p, q;
string a, b;
string na, nb;
int main() {
  cin >> n >> a >> b;
  la = a.length();
  lb = b.length();
  k = la * lb;
  for (i = 0; i <= lb - 1; i++)
    for (j = 0; j <= la - 1; j++) na += a[j];
  for (i = 0; i <= la - 1; i++)
    for (j = 0; j <= lb - 1; j++) nb += b[j];
  for (i = 0; i <= k; i++) {
    if (na[i] == nb[i]) continue;
    if (na[i] == 'P' && nb[i] == 'S' || na[i] == 'S' && nb[i] == 'R' ||
        na[i] == 'R' && nb[i] == 'P')
      sa++;
    else
      sb++;
  }
  p = n / k;
  q = n % k;
  sa *= p;
  sb *= p;
  for (i = 0; i < q; i++) {
    if (na[i] == nb[i]) continue;
    if (na[i] == 'P' && nb[i] == 'S' || na[i] == 'S' && nb[i] == 'R' ||
        na[i] == 'R' && nb[i] == 'P')
      sa++;
    else
      sb++;
  }
  cout << sa << " " << sb;
}
