#include <bits/stdc++.h>
using namespace std;
vector<int> v[26];
long long sf[26][200020], sb[26][200020];
char s1[200020], s2[200020];
int main() {
  int n;
  scanf("%d%s%s", &n, s1, s2);
  for (int i = 0; i < n; ++i) v[s2[i] - 'A'].push_back(i);
  for (int i = 0; i < 26; ++i) {
    for (int j = 0; j < v[i].size(); ++j)
      if (j == 0)
        sf[i][j] = v[i][j] + 1;
      else
        sf[i][j] = sf[i][j - 1] + v[i][j] + 1;
    for (int j = v[i].size() - 1; j >= 0; --j)
      if (j == v[i].size() - 1)
        sb[i][j] = n - v[i][j];
      else
        sb[i][j] = sb[i][j + 1] + n - v[i][j];
  }
  long long tot = n * (long long)(n + 1) * (2 * n + 1) / 6;
  double ans = 0;
  for (int i = 0; i < n; ++i) {
    int id = s1[i] - 'A';
    int p = lower_bound(v[id].begin(), v[id].end(), i) - v[id].begin();
    long long ct = 0;
    if (p != 0) ct = (long long)(n - i) * sf[id][p - 1];
    if (p != v[id].size()) ct += (long long)(i + 1) * sb[id][p];
    ans += ct / (double)tot;
  }
  printf("%.9f\n", ans);
  return 0;
}
