#include <bits/stdc++.h>
using namespace std;
void prepare() {}
const int MAX = 1e7 + 10;
const int SMAX = sqrt(MAX + .0) + 5;
int sqr[MAX];
void solve() {
  int n;
  cin >> n;
  int ans1 = 0, ans2 = 0;
  string s1, s2, ss1, ss2;
  cin >> s1 >> s2;
  ss1 = s1;
  ss2 = s2;
  while (s1.size() != s2.size()) {
    if (s1.size() < s2.size())
      s1 += ss1;
    else
      s2 += ss2;
  }
  int t1 = 0, t2 = 0;
  for (int i = 0; i < s1.size(); ++i) {
    if (s1[i] == 'R') {
      if (s2[i] == 'S')
        ++t2;
      else if (s2[i] == 'P')
        ++t1;
    }
    if (s1[i] == 'S') {
      if (s2[i] == 'P')
        ++t2;
      else if (s2[i] == 'R')
        ++t1;
    }
    if (s1[i] == 'P') {
      if (s2[i] == 'R')
        ++t2;
      else if (s2[i] == 'S')
        ++t1;
    }
  }
  int p = n / s1.size();
  ans1 = p * t1;
  ans2 = p * t2;
  for (int i = 0; i < n - p * s1.size(); ++i) {
    if (s1[i] == 'R') {
      if (s2[i] == 'S')
        ++ans2;
      else if (s2[i] == 'P')
        ++ans1;
    }
    if (s1[i] == 'S') {
      if (s2[i] == 'P')
        ++ans2;
      else if (s2[i] == 'R')
        ++ans1;
    }
    if (s1[i] == 'P') {
      if (s2[i] == 'R')
        ++ans2;
      else if (s2[i] == 'S')
        ++ans1;
    }
  }
  cout << ans1 << " " << ans2 << endl;
}
int main() {
  prepare();
  solve();
  return 0;
}
