#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000000000000000ll;
const int maxn = 200005;
char a[maxn], b[maxn];
long long l[maxn], r[maxn], p[maxn];
int main() {
  int N;
  scanf("%d", &N);
  scanf("%s", a + 1);
  scanf("%s", b + 1);
  long long tot = 0, ans = 0;
  for (int i = 1; i <= N; ++i)
    tot += (((long long)N - i + 1) * ((long long)N - i + 1));
  double ret = 0;
  for (char c = 'A'; c <= 'Z'; ++c) {
    int M = 0;
    for (int i = 1; i <= N; ++i)
      if (a[i] == c) {
        ++M;
        p[M] = i;
      }
    memset(l, 0, sizeof(l));
    memset(r, 0, sizeof(r));
    for (int i = 1; i <= M; ++i) l[i] = l[i - 1] + p[i];
    for (int i = M; i >= 1; --i) r[i] = r[i + 1] + (N - p[i] + 1);
    for (int i = 1, j = 1; i <= N; ++i)
      if (b[i] == c) {
        while (j <= M && p[j] <= i) ++j;
        ans += (long long)l[j - 1] * (N - i + 1);
        ans += (long long)i * r[j];
        if (ans >= mod) {
          ret += (double)mod / tot * (ans / mod);
          ans %= mod;
        }
      }
  }
  printf("%.10lf\n", ret + (double)ans / tot);
  return 0;
}
