#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:10034217728")
using namespace std;
int n;
string a, b;
const int N = 30;
int A[N], B[N];
double sum = 0;
const int M = 2e5 + 100;
int main() {
  cin >> n >> a >> b;
  for (int i = 0; i < a.size(); i++) {
    a[i] -= 'A';
    b[i] -= 'A';
  }
  for (int l = 1; l <= n; l++) {
    sum += (n - l + 1.) * (n - l + 1.);
  }
  double ans = 0;
  for (int j = 0; j < 26; j++) {
    vector<double> S(n + 1);
    vector<double> G(n + 1);
    vector<double> SG(n + 1);
    double s = 0, g = 0;
    for (int i = 0; i < n; i++) {
      S[i + 1] = S[i];
      G[i + 1] = G[i];
      if (a[i] == j) S[i + 1]++;
      if (b[i] == j) G[i + 1]++;
      SG[i + 1] = SG[i];
      SG[i + 1] += S[i + 1] * G[i + 1];
    }
    vector<double> GG(n + 1), SS(n + 1);
    for (int i = 0; i < n; i++) {
      SS[i + 1] = SS[i];
      SS[i + 1] += S[i + 1];
      GG[i + 1] = GG[i];
      GG[i + 1] += G[i + 1];
    }
    for (int i = 0; i < n; i++) {
      double mulres = SG[n] - SG[i] - g * (SS[n] - SS[i]) -
                      s * (GG[n] - GG[i]) + (n - i) * s * g;
      ans += mulres / sum;
      if (a[i] == j) s++;
      if (b[i] == j) g++;
    }
  }
  printf("%.15lf", ans);
  return 0;
}
