#include <bits/stdc++.h>
int main() {
  int n, a = 0, b = 0, i, l2, l1, flag = 1, s1 = 0, s2 = 0, T;
  char str1[1010], str2[1010];
  scanf("%d", &n);
  scanf("%s%s", str1, str2);
  l1 = strlen(str1);
  l2 = strlen(str2);
  for (i = 1; i <= n; i++) {
    if (a == 0 && b == 0 && i != 1 && flag == 1) {
      flag = 0;
      T = n / (i - 1);
      s1 = s1 * T;
      s2 = s2 * T;
      i = (i - 1) * T;
      continue;
    }
    if (str1[a] == str2[b])
      ;
    else if (str1[a] == 'S' && str2[b] == 'P')
      s1++;
    else if (str1[a] == 'S' && str2[b] == 'R')
      s2++;
    else if (str1[a] == 'R' && str2[b] == 'P')
      s2++;
    else if (str1[a] == 'R' && str2[b] == 'S')
      s1++;
    else if (str1[a] == 'P' && str2[b] == 'S')
      s2++;
    else if (str1[a] == 'P' && str2[b] == 'R')
      s1++;
    a++;
    b++;
    if (a == l1) a = a % l1;
    if (b == l2) b = b % l2;
  }
  printf("%d %d\n", s2, s1);
  return 0;
}
