#include <bits/stdc++.h>
using namespace std;
long long Count[3][30];
int main() {
  int N;
  cin >> N;
  string S1, S2;
  cin >> S1 >> S2;
  double res = 0;
  for (int n = 0; n < N; ++n) {
    Count[0][S1[n] - 'A'] += n + 1;
    res += (double)((N - n) * 1ll *
                    (Count[1][S1[n] - 'A'] + 0ll + Count[0][S2[n] - 'A'])) /
           (double)(N * 1ll * (N + 1));
    Count[1][S2[n] - 'A'] += n + 1;
  }
  res *= 6.000;
  res /= (double)(2 * N + 1);
  printf("%.9lf\n", (double)res);
  return 0;
}
