#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string a, b;
  cin >> a >> b;
  long double ans = 0;
  for (char ch = 'A'; ch <= 'Z'; ch++) {
    long long x[200010], y[200010];
    x[0] = (a[0] == ch);
    y[0] = (b[0] == ch);
    for (int i = 1; i < n; i++) {
      x[i] = x[i - 1];
      if (ch == a[i]) x[i] += i + 1;
      y[i] = y[i - 1];
      if (ch == b[i]) y[i] += i + 1;
    }
    for (int i = 0; i < n; i++)
      if (a[i] == ch) ans += y[i] * (n - i);
    for (int i = 1; i < n; i++)
      if (b[i] == ch) ans += x[i - 1] * (n - i);
  }
  long long sum = 0;
  for (int i = 1; i <= n; i++) sum += (long long)i * i;
  cout.precision(15);
  cout << fixed << ans / sum;
  return 0;
}
