#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = ((ans % m) * (a % m)) % m;
    b /= 2;
    a = ((a % m) * (a % m)) % m;
  }
  return ans % m;
}
double cnt[26];
int main() {
  int n;
  cin >> n;
  string a, b;
  cin >> a >> b;
  double ans = 0.0;
  for (int i = 0; i < n; i++) {
    cnt[b[i] - 'A'] += (i + 1);
    ans += (double)(n - i) * cnt[a[i] - 'A'];
  }
  for (int i = 0; i < 26; i++) cnt[i] = 0.0;
  for (int i = 0; i < n; i++) {
    ans += (double)(n - i) * cnt[b[i] - 'A'];
    cnt[a[i] - 'A'] += (i + 1);
  }
  double deno = (((double)n) * (n + 1) * (2 * n + 1) / 6);
  ans = (double)ans / deno;
  cout << fixed << setprecision(12) << ans;
}
