#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000, N = 200000;
int n;
long long cnt[26];
char a[N + 5], b[N + 5];
int main() {
  scanf("%d %s %s", &n, a + 1, b + 1);
  double ans = 0, all = ((long long)n * (n + 1) / 2 * (2 * n + 1) / 3);
  for (int i = 1; i <= n; i++) {
    cnt[b[i] - 'A'] += i;
    ans += cnt[a[i] - 'A'] * (n - i + 1) / all;
  }
  memset(cnt, 0, sizeof cnt);
  for (int i = 1; i <= n; i++) cnt[a[i] - 'A'] += i;
  for (int i = n; i >= 1; i--) {
    cnt[a[i] - 'A'] -= i;
    ans += cnt[b[i] - 'A'] * (n - i + 1) / all;
  }
  printf("%.9lf\n", ans);
  return 0;
}
