#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647, maxN = 200000 + 10;
int N;
char A[maxN], B[maxN];
long long cnt[26 + 10], cnt2[26 + 10];
double f[maxN];
void setIO(string name) {
  string in = name + ".in";
  string out = name + ".out";
  freopen(in.c_str(), "r", stdin);
  freopen(out.c_str(), "w", stdout);
}
int main() {
  scanf("%d\n", &N);
  scanf("%s\n", A);
  scanf("%s\n", B);
  for (int i = 0; i < 26; ++i) cnt[i] = cnt2[i] = 0;
  long long a = 0, i;
  for (i = 1; i <= N; ++i) {
    long long t = i * i;
    a += t;
  }
  f[0] = 0;
  for (int i = 0; i < N; ++i) {
    f[i + 1] = f[i] + (double)cnt2[A[i] - 'A'] / a * (N - i) +
               (double)cnt[B[i] - 'A'] / a * (N - i);
    if (A[i] == B[i]) f[i + 1] += (double)(i + 1) / a * (N - i);
    cnt[A[i] - 'A'] += i + 1;
    cnt2[B[i] - 'A'] += i + 1;
  }
  printf("%.6lf\n", f[N]);
  return 0;
}
