#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 9;
const long long MOD = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  string a, b;
  cin >> n >> a >> b;
  double sum = 0;
  long long p = 0;
  for (int i = 1; i <= n; i++) p += 1LL * i * i;
  for (char c = 'A'; c <= 'Z'; c++) {
    long long s1 = 0, s2 = 0;
    for (int t = 0; t < n; t++) {
      if (a[t] == c) {
        sum += (double)s2 * (n - t) / p;
        s1 += t + 1;
      }
      if (b[t] == c) {
        sum += (double)s1 * (n - t) / p;
        s2 += t + 1;
      }
    }
  }
  cout << fixed << setprecision(10) << sum << "\n";
}
