#include <bits/stdc++.h>
using namespace std;
int n;
long double f[200111][30];
string a, b;
long double calc(int z) {
  memset(f, 0, sizeof(f));
  long double res = 0;
  for (int i = 1; i <= n; i++) {
    for (int c = 0; c <= 25; c++)
      if (c == b[i] - 'A')
        f[i][c] = f[i - 1][c] + i;
      else
        f[i][c] = f[i - 1][c];
    res += f[i - z][a[i] - 'A'] * (n - i + 1);
  }
  return res;
}
int main() {
  cin >> n >> a >> b;
  a = " " + a;
  b = " " + b;
  long double ms = 0;
  for (int i = 1; i <= n; i++) ms += (long double)i * i;
  long double ts = calc(0);
  swap(a, b);
  ts += calc(1);
  printf("%.9lf", (double)ts / (double)ms);
}
