#include <bits/stdc++.h>
using namespace std;
string s1, s2;
long long vals[200005], rev[200005];
int main() {
  ios_base::sync_with_stdio(false);
  long long n, i, j;
  cin >> n;
  cin >> s1 >> s2;
  for (i = 0; i < 26; i++) {
    vals[i] = rev[i] = 0;
  }
  long long den = n * (n + 1) * (2 * n + 1) / 6;
  double ans = 0;
  for (i = n - 1; i >= 0; i--) {
    vals[s2[i] - 'A'] += (n - i);
    ans += 1.0 * ((i + 1) * (vals[s1[i] - 'A'])) / den;
  }
  for (i = n - 1; i >= 0; i--) {
    ans += 1.0 * (rev[s2[i] - 'A'] * (i + 1)) / den;
    rev[s1[i] - 'A'] += (n - i);
  }
  printf("%.12lf\n", ans);
  return 0;
}
