#include <bits/stdc++.h>
using namespace std;
const int N = 200004;
vector<long long> a[27], b[27];
char sa[N], sb[N];
long long s[N], z[N];
int n;
int main() {
  scanf("%d %s %s", &n, sa + 1, sb + 1);
  for (int i = 1; i <= n; i++) {
    a[sa[i] - 'A'].push_back(i);
    b[sb[i] - 'A'].push_back(i);
  }
  double ans = 0;
  for (int r = 0; r < 26; r++) {
    for (int i = 0; i < b[r].size(); i++) {
      z[i + 1] = b[r][i];
      s[i + 1] = s[i] + z[i + 1];
    }
    int m = b[r].size();
    for (long long x : a[r]) {
      int p = upper_bound(z + 1, z + m + 1, x) - z - 1;
      ans += s[p] * (n + 1 - x) + x * (1ll * (n + 1) * (m - p) - s[m] + s[p]);
    }
  }
  ans /= n;
  ans /= n + 1;
  ans /= 2 * n + 1;
  ans *= 6;
  printf("%.10f\n", ans);
}
