#include <bits/stdc++.h>
using namespace std;
long double z, t = 0;
int n;
char x[200005], y[200005];
long long s[200005], f[256];
int main() {
  scanf("%d\n", &n);
  gets(x);
  gets(y);
  for (int i = 0; i < n; i++) {
    f[y[i]] += i + 1;
    s[i] = f[x[i]];
  }
  z = 0;
  for (int i = 0; i < n; i++) {
    z += s[i] * (n - i);
  }
  for (int i = 0; i < n; i++) {
    f[y[i]] = 0;
    s[x[i]] = 0;
  }
  for (int i = 0; i < n; i++) {
    s[i] = f[y[i]];
    f[x[i]] += i + 1;
  }
  for (int i = 0; i < n; i++) {
    z += s[i] * (n - i);
  }
  for (int i = 1; i <= n; i++) t += 1ll * (n - i + 1) * (n - i + 1);
  z /= t;
  cout << fixed << setprecision(10) << z << "\n";
  return 0;
}
