#include <bits/stdc++.h>
using namespace std;
long long int sf[26][200005], tf[26][200005];
int main() {
  long long int n, i, j;
  cin >> n;
  double ans = 0.0;
  string s, t;
  cin >> s >> t;
  for (i = 0; i < n; ++i) {
    sf[s[i] - 'A'][i] += (i + 1);
    tf[t[i] - 'A'][i] += (i + 1);
    if (i)
      for (j = 0; j < 26; ++j) {
        sf[j][i] += sf[j][i - 1];
        tf[j][i] += tf[j][i - 1];
      }
    ans = ans + (n - i) * ((i ? sf[t[i] - 'A'][i - 1] : 0) + tf[s[i] - 'A'][i]);
  }
  ans = (6 * ans) / (n * (n + 1) * (2 * n + 1));
  cout << fixed << setprecision(8) << ans;
  return 0;
}
