#include <bits/stdc++.h>
using namespace std;
long long n, cnt_a[255], cnt_b[255];
double ret;
string a, b;
int main() {
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) {
    cnt_a[b[i]] += i + 1;
    ret += (n - i) * (cnt_a[a[i]] + cnt_b[b[i]]);
    cnt_b[a[i]] += i + 1;
  }
  printf("%.7lf", 6 * ret / n / (n + 1) / (2 * n + 1));
  return 0;
}
