#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n;
char a[N], b[N];
vector<int> pa[30];
vector<int> pb[30];
vector<long long> dd[30];
double ans;
long long total;
long long cnt(int p, int i) {
  int split = lower_bound(pb[i].begin(), pb[i].end(), p) - pb[i].begin();
  int sz = pb[i].size();
  long long cright = 1ll * (sz - split) * n - (dd[i][sz] - dd[i][split]);
  long long cleft = dd[i][split] + 1ll * split;
  return cright * (p + 1) + cleft * (n - p);
}
int main() {
  scanf("%d", &n);
  scanf("%s%s", a, b);
  for (int i = 0; i < n; ++i) {
    pa[a[i] - 'A'].push_back(i);
  }
  for (int i = 0; i < n; ++i) {
    pb[b[i] - 'A'].push_back(i);
  }
  for (int i = 0; i < 26; ++i) {
    dd[i].push_back(0);
    for (int j = 0; j < pb[i].size(); ++j) {
      dd[i].push_back(dd[i][j] + pb[i][j]);
    }
  }
  for (int i = 0; i < 26; ++i) {
    for (auto p : pa[i]) {
      ans += cnt(p, i);
    }
  }
  for (int i = 1; i <= n; ++i) {
    total += 1ll * (n + 1 - i) * (n + 1 - i);
  }
  printf("%.10f\n", ans / total);
  return 0;
}
