#include <bits/stdc++.h>
const int inf = 0x7FFFFFFF;
using namespace std;
vector<int> pos[128];
double l[200010], r[200010];
int last[128];
string sr, sr2;
int main() {
  int N;
  scanf("%d", &N);
  double ans = 1.0 * N * (N + 1) * (2 * N + 1) / 6, fenzi = 0;
  cin >> sr;
  cin >> sr2;
  int L = sr.length();
  memset(last, -1, sizeof(last));
  for (int i = 0; i < L; i++) {
    pos[sr[i]].push_back(i);
    if (last[sr[i]] == -1) {
      l[i] = i + 1;
    } else {
      l[i] = l[last[sr[i]]] + i + 1;
    }
    last[sr[i]] = i;
  }
  memset(last, -1, sizeof(last));
  for (int i = L - 1; i >= 0; i--) {
    if (last[sr[i]] == -1) {
      r[i] = L - i;
    } else {
      r[i] = r[last[sr[i]]] + L - i;
    }
    last[sr[i]] = i;
  }
  for (int i = 0; i < L; i++) {
    char c = sr2[i];
    int sz = pos[c].size();
    if (sz == 0) continue;
    int k = lower_bound(pos[c].begin(), pos[c].end(), i) - pos[c].begin();
    if (k == sz) {
      fenzi += l[pos[c][sz - 1]] * (L - i);
    } else if (pos[c][k] == i) {
      fenzi += l[i] * (L - i) + r[i] * (i + 1) - (i + 1.0) * (L - i);
    } else {
      fenzi += r[pos[c][k]] * (i + 1);
      if (k) fenzi += l[pos[c][k - 1]] * (L - i);
    }
  }
  ans = fenzi / ans;
  printf("%.10lf\n", ans);
  return 0;
}
