#include <bits/stdc++.h>
using namespace std;
int n;
char x[201010], y[201010];
double sl[201010], sr[201010];
double last_s[300];
vector<int> p[300];
vector<int>::iterator it;
int main() {
  scanf("%d", &n);
  scanf("%s%s", &x, &y);
  double tot = 1LL * n * (n + 1) * (2 * n + 1) / 6;
  memset(sl, 0, sizeof sl);
  memset(sr, 0, sizeof sr);
  memset(last_s, 0, sizeof last_s);
  for (int i = 0; i < n; i++) sl[i] = last_s[y[i]] += i + 1;
  memset(last_s, 0, sizeof last_s);
  for (int i = n - 1; i >= 0; i--) sr[i] = last_s[y[i]] += n - i;
  for (int i = 'A'; i <= 'Z'; i++) p[i].clear();
  for (int i = 0; i < n; i++) p[y[i]].push_back(i);
  double res = 0;
  for (int i = 0; i < n; i++) {
    char ch = x[i];
    it = lower_bound(p[ch].begin(), p[ch].end(), i);
    if (it != p[ch].end()) res += 1LL * (i + 1) * sr[(*it)];
    if (it != p[ch].begin()) {
      it--;
      res += 1LL * (n - i) * sl[(*it)];
    }
  }
  printf("%.10lf\n", res / tot);
  return 0;
}
