#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  char ch = getchar();
  int fh = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') fh = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x *= fh;
}
template <typename T>
void write(T x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
void writeln(T x) {
  write(x);
  puts("");
}
int n;
char a[200005];
char b[200005];
vector<int> ida[26], idb[26];
long long pre[200005], suf[200005];
signed main() {
  read(n);
  scanf("%s", a + 1);
  scanf("%s", b + 1);
  for (int i = 1; i <= n; ++i) ida[a[i] - 'A'].push_back(i);
  for (int i = 1; i <= n; ++i) idb[b[i] - 'A'].push_back(i);
  long double ans = 0;
  long long chs =
      (long long)n * (long long)(n + 1) * (long long)(2 * n + 1) / 6;
  for (int i = 0; i < 26; ++i) {
    for (int j = 1; j <= n; ++j) pre[j] = suf[j] = 0;
    for (int j : idb[i]) {
      pre[j] = j;
      suf[j] = n - j + 1;
    }
    for (int j = 1; j <= n; ++j) pre[j] += pre[j - 1];
    for (int j = n; j >= 1; --j) suf[j] += suf[j + 1];
    long double res = 0;
    for (int j : ida[i]) {
      res += (long double)pre[j] / (long double)chs * (long double)(n - j + 1);
      res += (long double)suf[j + 1] / (long double)chs * (long double)j;
    }
    ans += res;
  }
  printf("%.9Lf\n", ans);
  return 0;
}
