#include <bits/stdc++.h>
using namespace std;
const int max_n = 200100;
const bool debug = false;
char a[max_n], b[max_n];
long long sa[max_n], sb[max_n], dw, n;
double ans;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) cin >> b[i];
  dw = 0;
  for (int i = 1; i <= n; i++) dw += (n - i + 1) * (n - i + 1);
  for (int i = 0; i < 26; i++) {
    long long cur = 0;
    for (int j = 1; j <= n; j++) {
      if (b[j] == i + 'A') cur += j;
      if (a[j] == i + 'A') sa[j] = cur;
    }
    cur = 0;
    for (int j = 1; j <= n; j++) {
      if (b[j] == i + 'A') sb[j] = cur;
      if (a[j] == i + 'A') cur += j;
    }
  }
  ans = 0;
  for (int i = 1; i <= n; i++) {
    long long cur = (sa[i] * (n - i + 1));
    ans += double(cur) / double(dw);
    cur = (sb[i] * (n - i + 1));
    ans += double(cur) / double(dw);
  }
  printf("%f", ans);
  return 0;
}
