#include <bits/stdc++.h>
using namespace std;
char a[300000];
char b[300000];
vector<int> v[30];
vector<int> w[30];
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s %s", a, b);
  double all = 0;
  for (int i = 'A'; i <= 'Z'; i++) {
    double sum1 = 0, sum2 = 0;
    for (int j = 0; j < n; j++) {
      if (a[j] == i) {
        all += sum2 * (n - j);
        sum1 += j + 1;
      }
      if (b[j] == i) {
        all += sum1 * (n - j);
        sum2 += j + 1;
      }
    }
  }
  double div = n * (n + 1.0) * (2.0 * n + 1.0) / 6.0;
  all /= div;
  printf("%.20lf\n", all);
}
