#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long maxn = 3e6;
const long long mod = 1e9 + 7;
const long double PI = acos((long double)-1);
long long pw(long long a, long long b, long long md = mod) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = (a * res) % md;
    }
    a = (a * a) % md;
    b >>= 1;
  }
  return (res);
}
long double n;
string a, b;
long double all;
long double sum[27];
long double ans;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  cin >> a >> b;
  a = "$" + a;
  b = "$" + b;
  all = n * (n + 1) * (2 * n + 1) / 6;
  for (int i = 1; i <= n; i++) {
    sum[b[i] - 'A'] += (n - i + 1);
  }
  for (int i = 1; i <= n; i++) {
    ans += sum[a[i] - 'A'] * (i);
    sum[b[i] - 'A'] -= (n - i + 1);
  }
  for (int i = 1; i <= n; i++) {
    sum[b[i] - 'A'] += i;
  }
  for (int i = n; i > 0; i--) {
    sum[b[i] - 'A'] -= i;
    ans += ((n - i + 1) * sum[a[i] - 'A']);
  }
  cout << fixed << (ans / all);
  return (0);
}
