#include <bits/stdc++.h>
using namespace std;
int main() {
  int q, w, e, r, t;
  long double y = 0, u = 0;
  char a[200001], s[200001];
  long long d[26], f[26];
  for (w = 0; w < 26; w++) d[w] = f[w] = 0;
  cin >> q;
  for (w = 1; w <= q; w++) u += ((long long)w) * ((long long)w);
  scanf("%s%s", a, s);
  for (w = q - 1; w >= 0; w--) {
    s[w] -= 65;
    f[s[w]] += q - w;
  }
  for (w = 0; w < q; w++) {
    d[s[w]] += w + 1;
    f[s[w]] -= q - w;
    a[w] -= 65;
    y += d[a[w]] * ((long long)(q - w)) + ((long long)(w + 1)) * f[a[w]];
  }
  y /= u;
  cout << (int)y << '.';
  for (w = 0; w < 7; w++) {
    y -= (int)y;
    y *= 10;
    cout << (int)y;
  }
  return 0;
}
