#include <bits/stdc++.h>
using namespace std;
long long aa[258], bb[258];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0), cerr << "";
  string a, b;
  long long n;
  cin >> n;
  cin >> a >> b;
  long double s = 0;
  for (int i = 1; i <= n; ++i)
    aa[b[i - 1]] += i,
        s += (n - i + 1) * (aa[a[i - 1]] + bb[b[i - 1]]) * 1.0 / n,
        bb[a[i - 1]] += i;
  long double l = s * 1.0 / (n + 1) / (2 * n + 1);
  l *= 6.0;
  cout.precision(9);
  cout << fixed << l;
}
