#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  long long fir[30], sec[30];
  long double res;
  char c;
  int i = 0;
  int j;
  int n;
  cin >> n;
  cin >> a;
  cin >> b;
  for (c = 'A'; c <= 'Z'; c++) fir[c - 'A'] = 0;
  for (c = 'A'; c <= 'Z'; c++) sec[c - 'A'] = 0;
  res = 0.;
  for (i = 1; i <= n; i++) {
    j = n - i;
    res += sec[a[j] - 'A'] * (j + 1);
    res += fir[b[j] - 'A'] * (j + 1);
    if (a[j] == b[j]) res += (long long)(i) * (j + 1);
    fir[a[j] - 'A'] += i;
    sec[b[j] - 'A'] += i;
  }
  long long den = 0;
  for (i = 1; i <= n; i++) den += (long long)(i)*i;
  double q = res / den;
  printf("%.8lf\n", q);
  return 0;
}
