#include <bits/stdc++.h>
using namespace std;
const int N = 200003;
const int A = 26;
char buf[N];
long double sum[A];
string s, t;
int n;
long double calc() {
  for (int i = 0; i < A; ++i) sum[i] = 0;
  long double rv = 0;
  for (int i = 0; i < n; ++i) {
    int x = t[i] - 'A';
    sum[x] += i + 1;
    x = s[i] - 'A';
    rv += sum[x] * (n - i);
  }
  return rv;
}
int main() {
  scanf("%d%s", &n, buf);
  s = buf;
  scanf("%s", buf);
  t = buf;
  long double res = calc();
  swap(s, t);
  res += calc();
  for (int i = 0; i < n; ++i)
    if (s[i] == t[i]) res -= (long double)(i + 1) * (n - i);
  long double den = 0;
  for (int i = 1; i <= n; ++i) den += (long double)(n - i + 1) * (n - i + 1);
  printf("%lf\n", (double)(res / den));
  return 0;
}
