#include <bits/stdc++.h>
int const N = 200100;
char a[N];
char b[N];
long long sum[N];
int main() {
  int n;
  scanf("%d\n", &n);
  gets(a);
  gets(b);
  double ans = 0;
  for (int it = 0; it < 2; ++it) {
    for (char ch = 'A'; ch <= 'Z'; ++ch) {
      sum[0] = 0;
      for (int i = 0; i < n; ++i) {
        sum[i + 1] = sum[i];
        if (b[i] == ch) {
          sum[i + 1] += i + 1;
        }
      }
      for (int i = 0; i < n; ++i) {
        if (a[i] == ch) {
          ans += sum[i + 1] * (n - i);
        }
      }
    }
    std::swap(a, b);
  }
  for (int i = 0; i < n; ++i) {
    if (a[i] == b[i]) {
      ans -= 1LL * (i + 1) * (n - i);
    }
  }
  double all = 0;
  for (int i = 1; i <= n; ++i) {
    long long now = n + 1 - i;
    all += now * now;
  }
  printf("%.10f\n", ans / all);
  return 0;
}
