#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:10000000 /HEAP:10000000")
using namespace std;
int n;
long long int kol;
int search(vector<int> &v, int val) {
  int l = 0, r = v.size() - 1, c;
  while (r - l > 1) {
    c = (l + r) / 2;
    if (v[c] < val)
      l = c;
    else
      r = c;
  }
  if (v[l] >= val) return l;
  if (v[r] >= val) return r;
  return v.size();
}
double res(vector<int> &v1, vector<int> &v2) {
  if (!v1.size() || !v2.size()) return 0.0;
  vector<long long int> sum2(1);
  int i, pos;
  long long int ans = 0, sum = 0;
  double Ans = 0.0;
  for (i = 0; i < v2.size(); i++) sum2.push_back(sum2[i] + 1ll * v2[i]);
  for (i = 0; i < v1.size(); i++) {
    pos = search(v2, v1[i]);
    ans = 1ll * (n + 1) * (1ll * (v2.size() - pos) * v1[i] + sum2[pos]) -
          sum2.back() * v1[i];
    Ans += (double)ans / kol;
  }
  return Ans;
}
int main() {
  cin >> n;
  string s1, s2;
  vector<int> arr1[26];
  vector<int> arr2[26];
  int i;
  kol = 0;
  for (i = 1; i <= n; i++) kol += 1ll * i * i;
  cin >> s1 >> s2;
  for (i = 0; i < n; i++) arr1[s1[i] - 'A'].push_back(i + 1);
  for (i = 0; i < n; i++) arr2[s2[i] - 'A'].push_back(i + 1);
  double Res = 0;
  for (i = 0; i < 26; i++) Res += res(arr1[i], arr2[i]);
  cout.precision(8);
  cout << fixed << Res << endl;
  return 0;
}
