#include <bits/stdc++.h>
using namespace std;
char a[211111], b[211111];
long long s_a[211111], s_b[211111];
int main() {
  int n;
  long long mauso = 0;
  double res = 0.0;
  scanf("%d", &n);
  scanf("%s%s", a, b);
  for (int ch = 0, _b = 26; ch <= _b; ch++) {
    long long s = 0;
    char tmp = (char)(ch + 'A');
    for (int i = 1, _b = n; i <= _b; i++) {
      if (b[i - 1] == tmp) s += 1LL * i;
      if (a[i - 1] == tmp) res += 1LL * s * (n - i + 1);
    }
    s = 0;
    for (int i = n, _b = 1; i >= _b; i--) {
      if (a[i - 1] == tmp) res += 1LL * s * i;
      if (b[i - 1] == tmp) s += 1LL * (n - i + 1);
    }
  }
  for (int i = 1, _b = n; i <= _b; i++)
    mauso += 1LL * (n - i + 1) * (n - i + 1);
  printf("%.9lf\n", res * 1.0 / (mauso * 1.0));
  return 0;
}
