#include <bits/stdc++.h>
using namespace std;
char a[200010], b[200010];
double da[256], db[256], ans;
int main() {
  int n;
  scanf("%d%s%s", &n, a, b);
  for (int i = 0; i < n; i++) {
    db[b[i]] += i + 1;
    ans += (n - i) * (db[a[i]] + da[b[i]]);
    da[a[i]] += i + 1;
  }
  printf("%.10lf\n", ans * 6.0 / n / (2 * n + 1) / (n + 1));
}
