#include <bits/stdc++.h>
using namespace std;
long long l[200005], r[200005];
vector<long long> p[30], suml[30], sumr[30];
int main() {
  long long n, sum = 0;
  cin >> n;
  string a, b;
  cin >> a >> b;
  a = " " + a;
  b = " " + b;
  for (long long i = n; i >= 1; i--) {
    sum += i * i;
  }
  for (long long i = 1; i <= n; i++) {
    l[i] = i;
    r[i] = n + 1 - i;
  }
  for (long long i = 0; i < 26; i++) {
    p[i].push_back(0);
  }
  for (long long i = 1; i <= n; i++) {
    p[b[i] - 'A'].push_back(i);
  }
  for (long long i = 0; i < 26; i++) {
    long long pre = 0, sx = 0;
    for (auto v : p[i]) {
      pre += l[v];
      sx += r[v];
      suml[i].push_back(pre);
      sumr[i].push_back(sx);
    }
  }
  long double ans = 0.0;
  for (long long i = 1; i <= n; i++) {
    long long v = a[i] - 'A', sz = p[v].size() - 1;
    long long rx = lower_bound(p[v].begin(), p[v].end(), i) - p[v].begin(),
              lx = rx - 1;
    ans += (long double)l[i] * (long double)(sumr[v][sz] - sumr[v][lx]);
    ans += (long double)r[i] * (long double)suml[v][lx];
  }
  printf("%.15Lf\n", (long double)ans / (long double)sum);
}
