#include <bits/stdc++.h>
using namespace std;
const int _N = 200010;
long long n, bN[30], b[30][_N], fcnt[30][_N], bcnt[30][_N];
char a[_N];
int main() {
  ios::sync_with_stdio(false);
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(10);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  memset(bN, 0, sizeof(bN));
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    b[c - 'A'][bN[c - 'A']++] = i;
  }
  long long baseCnt = n * (n + 1) * (2 * n + 1) / 6;
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < bN[i]; j++)
      fcnt[i][j] = ((j == 0) ? 0 : fcnt[i][j - 1]) + (b[i][j] + 1);
    for (int j = bN[i] - 1; j >= 0; j--)
      bcnt[i][j] = ((j == bN[i] - 1) ? 0 : bcnt[i][j + 1]) + (n - b[i][j]);
  }
  long double ans = 0.0;
  for (int i = 0; i < n; i++)
    if (bN[a[i] - 'A'] > 0) {
      int j = lower_bound(b[a[i] - 'A'], b[a[i] - 'A'] + bN[a[i] - 'A'], i) -
              b[a[i] - 'A'];
      long long cnt = 0;
      if ((0 <= j - 1) && (j - 1 < bN[a[i] - 'A']))
        cnt += fcnt[a[i] - 'A'][j - 1] * (n - i);
      if ((0 <= j) && (j < bN[a[i] - 'A']))
        cnt += bcnt[a[i] - 'A'][j] * (i + 1);
      ans += (long double)cnt / (long double)baseCnt;
    }
  cout << ans << endl;
  return 0;
}
