#include <bits/stdc++.h>
using namespace std;
const int oo = 1 << 30;
const double PI = M_PI;
const double EPS = 1e-15;
const int MaxN = 200005;
int n;
char A[MaxN];
char B[MaxN];
long long sum[26];
int main() {
  cin.sync_with_stdio(false);
  cin >> n;
  cin >> (A + 1);
  cin >> (B + 1);
  long long total = 0;
  for (int i = 1; i <= n; i++) total = total + (long long)i * (long long)i;
  for (int j = 1; j <= n; j++) sum[B[j] - 'A'] += (n - j + 1);
  double answer = 0;
  for (int i = 1; i <= n; i++) {
    answer = answer + ((long long)i * sum[A[i] - 'A']) / (double)total;
    sum[B[i] - 'A'] -= (n - i + 1);
  }
  for (int j = 1; j <= n; j++) sum[B[j] - 'A'] += j;
  for (int i = n; i >= 1; i--) {
    sum[B[i] - 'A'] -= i;
    answer =
        answer + ((long long)(n - i + 1) * sum[A[i] - 'A']) / (double)total;
  }
  cout.precision(10);
  cout << fixed << answer << endl;
  return 0;
}
