#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string a, b;
  cin >> n;
  cin >> a;
  cin >> b;
  long long target = n * (long long)(n + 1) * (2 * n + 1) / 6;
  double res = 0;
  for (char ch = 'A'; ch <= 'Z'; ch++) {
    long long sum = 0;
    for (int i = 0; i < n; i++) {
      if (b[i] == ch) sum += i + 1;
      if (a[i] == ch) res += (n - i) * sum;
    }
    sum = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (a[i] == ch) res += (i + 1) * sum;
      if (b[i] == ch) sum += n - i;
    }
  }
  printf("%.10f\n", res / (double)target);
  return 0;
}
