#include <bits/stdc++.h>
using namespace std;
const int N = 210000;
long long n;
string s, t;
double res;
double sum[30][N], sum2[30][N];
double ans, all;
int main() {
  cin >> n;
  cin >> s >> t;
  for (long long i = 0; i < n; i++) {
    s[i] -= 'A';
    t[i] -= 'A';
  }
  for (long long i = 0; i < n; i++) {
    for (long long let = 0; let < 26; let++) {
      if (let == t[i]) {
        if (i == 0)
          sum[let][i] = 1;
        else
          sum[let][i] = sum[let][i - 1] + i + 1;
      } else {
        if (i == 0)
          sum[let][i] = 0;
        else
          sum[let][i] = sum[let][i - 1];
      }
    }
  }
  for (long long i = n - 1; i >= 0; i--) {
    for (long long let = 0; let < 26; let++) {
      if (let == t[i]) {
        if (i == n - 1)
          sum2[let][i] = 1;
        else
          sum2[let][i] = sum2[let][i + 1] + n - i;
      } else {
        if (i == n - 1)
          sum2[let][i] = 0;
        else
          sum2[let][i] = sum2[let][i + 1];
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    res += sum[s[i]][i] * (n - i);
  }
  for (long long i = 0; i < n; i++) {
    res += (i + 1) * sum2[s[i]][i + 1];
  }
  for (long long i = 1; i <= n; i++) {
    all += i * i;
  }
  ans = res / all;
  printf("%.19lf", ans);
}
