#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
long long n;
double r[N][30], l[N][30], ans, tot;
char s[N], t[N];
int main() {
  cin >> n;
  scanf("%s%s", s + 1, t + 1);
  for (int i = n; i >= 1; i--) {
    for (int j = 0; j <= 25; j++) r[i][j] = r[i + 1][j];
    r[i][t[i] - 'A'] += n - i + 1;
  }
  for (int i = 1; i <= n; i++) ans += 1ll * i * r[i][s[i] - 'A'];
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 25; j++) l[i][j] = l[i - 1][j];
    l[i][t[i] - 'A'] += i;
  }
  for (int i = n; i >= 1; i--) ans += 1ll * (n - i + 1) * l[i - 1][s[i] - 'A'];
  for (int i = 1; i <= n; i++) tot += 1ll * i * i;
  printf("%.9lf\n", ans / tot);
  return 0;
}
