#include <bits/stdc++.h>
using namespace std;
long double second[32][200100] = {0};
long double first[32][200100] = {0};
int main() {
  long long n;
  string s, t;
  cin >> n >> s >> t;
  long double res = 0;
  long long tot = 0;
  for (long long i = 0; i < n; i++) tot += (i + 1) * (i + 1);
  long double div = (long double)1 / (long double)tot;
  for (long long i = 0; i < n; i++) {
    if (i > 0)
      for (int(j) = 0; (j) < (30); (j)++) second[j][i] = second[j][i - 1];
    second[t[i] - 'A'][i] += ((long double)i + 1) * div;
    if (i > 0)
      for (int(j) = 0; (j) < (30); (j)++) first[j][i] = first[j][i - 1];
    first[s[i] - 'A'][i] += ((long double)i + 1) * div;
  }
  for (long long i = 0; i < n; i++) res += second[s[i] - 'A'][i] * (n - i);
  for (long long i = 1; i < n; i++) res += first[t[i] - 'A'][i - 1] * (n - i);
  cout << fixed << setprecision(10) << res << endl;
}
