#include <bits/stdc++.h>
using namespace std;
int n, m;
string str1, str2;
int ans1, ans2;
int who(char a, char b) {
  if ((a == 'P' && b == 'S') || (a == 'S' && b == 'R') ||
      (a == 'R' && b == 'P'))
    return 1;
  if ((a == 'S' && b == 'P') || (a == 'R' && b == 'S') ||
      (a == 'P' && b == 'R'))
    return -1;
  return 0;
}
void fun1() {
  int i = 0, j = 0;
  while (true) {
    int w = who(str1[i], str2[j]);
    if (w == 1) {
      ans1++;
    } else if (w == -1)
      ans2++;
    i++, j++, m++;
    if (i == str1.size()) i = 0;
    if (j == str2.size()) j = 0;
    if (i == 0 && j == 0) {
      break;
    }
  }
}
void fun2() {
  int mod = n % m, x = n / m;
  ans1 *= x;
  ans2 *= x;
  int i = 0, j = 0;
  while (mod--) {
    int w = who(str1[i], str2[j]);
    if (w == 1) {
      ans1++;
    } else if (w == -1)
      ans2++;
    i++, j++;
    if (i == str1.size()) i = 0;
    if (j == str2.size()) j = 0;
  }
}
int main(int argc, char** argv) {
  while (cin >> n) {
    ans1 = ans2 = m = 0;
    cin >> str1 >> str2;
    fun1();
    fun2();
    cout << ans1 << " " << ans2 << endl;
  }
  return 0;
}
