#include <bits/stdc++.h>
using namespace std;
char a[210000], b[210000];
long long n, s[210000];
double cal(char c) {
  double res = 0;
  s[n] = 0;
  for (int i = n, j = 1; i > 0; --i, ++j) {
    s[i - 1] = s[i];
    if (a[i - 1] == c) s[i - 1] += j;
    if (b[i - 1] == c) res += s[i - 1] * i;
  }
  s[0] = 0;
  for (int i = 1, j = n; i <= n; ++i, --j) {
    s[i] = s[i - 1];
    if (a[i - 1] == c) s[i] += i;
    if (b[i - 1] == c) res += s[i - 1] * j;
  }
  return res;
}
int main() {
  cin >> n;
  scanf("%s", a);
  scanf("%s", b);
  double res = 0;
  for (int i = 0; i < 26; ++i) res += cal(char('A' + i));
  long long sum = 0;
  for (long long i = 1; i <= n; ++i) sum += i * i;
  printf("%.10lf\n", (res + 0.0) / (sum + 0.0));
  return 0;
}
