#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
template <class T>
T sq(T x) {
  return x * x;
}
const long long inf = 2147383647;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
const long long maxint = 2147483647;
const long long minint = -2147483648;
char buf1[300000], buf2[300000];
long long n;
double calc(char c) {
  long long right = 0, left = 0;
  int i;
  for (i = 0; i < n; i++) {
    if (buf2[i] == c) {
      right += n - i;
    }
  }
  double res = 0;
  for (i = 0; i < n; i++) {
    if (buf1[i] == c) {
      res += (i + 1) * right;
      res += (n - i) * left;
    }
    if (buf2[i] == c) {
      right -= n - i;
      left += i + 1;
    }
  }
  return res;
}
int main() {
  scanf("%lld", &n);
  scanf("%s %s", buf1, buf2);
  long long i;
  double res = 0, total = 0;
  for (i = 'A'; i <= 'Z'; i++) res += calc(i);
  for (i = 1; i <= n; i++) total += i * i;
  printf("%.15lf\n", res / total);
  return 0;
}
