#include <bits/stdc++.h>
using namespace std;
double solve(long long N, const string& A, const string& B) {
  long long Abs[26] = {}, Bbs[26] = {};
  double cnt = 0;
  for (int i = N - 1; i >= 0; --i) {
    cnt += (i + 1) * Abs[B[i] - 'A'];
    for (int c = 0; c < 26; ++c) {
      if (A[i] - 'A' == c) Abs[c] += (N - i);
      if (B[i] - 'A' == c) Bbs[c] += (N - i);
    }
    cnt += (i + 1) * Bbs[A[i] - 'A'];
  }
  double total = 0;
  for (long long n = 1; n <= N; ++n) total += (N - n + 1) * (N - n + 1);
  return cnt / total;
}
int main() {
  for (int n; cin >> n;) {
    string a, b;
    cin >> a >> b;
    cout << setiosflags(ios::fixed) << setprecision(9) << solve(n, a, b)
         << endl;
  }
}
