#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int n, pos[26][N], cnt[26];
double s1[26][N], s2[26][N];
char a[N], b[N];
void Init() {}
void GetData() { scanf("%d%s%s", &n, a + 1, b + 1); }
void Solve() {
  int i, j, p;
  double ans, down;
  ans = down = 0.0;
  for (i = 1; i <= n; ++i) {
    down += (double)i * i;
    j = b[i] - 'A';
    pos[j][++cnt[j]] = i;
    s1[j][cnt[j]] = s1[j][cnt[j] - 1] + i;
    s2[j][cnt[j]] = s2[j][cnt[j] - 1] + n - i + 1;
  }
  for (i = 1; i <= n; ++i) {
    j = a[i] - 'A';
    if (cnt[j] == 0) continue;
    p = lower_bound(pos[j] + 1, pos[j] + cnt[j] + 1, i) - pos[j];
    ans += (s1[j][p - 1] - s1[j][0]) * (n - i + 1) / down;
    ans += (s2[j][cnt[j]] - s2[j][p - 1]) * i / down;
  }
  printf("%.10lf\n", ans);
}
int main() {
  Init();
  GetData();
  Solve();
  return 0;
}
