#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
const int INF = 1e9 + 7;
const int MOD = 1e6 + 3;
const double Pi = acos(-1.0);
const double EPS = 1e-8;
int n;
char s[N], t[N];
vector<int> a, b;
double solve() {
  long long P = 0, Q = 1ll * n * (n + 1) * (2 * n + 1) / 6;
  double ret = 0.0;
  for (int c = (0); c < (26); ++c) {
    char ch = 'A' + c;
    a.clear(), b.clear();
    for (int i = (0); i < (n); ++i) {
      if (s[i] == ch) a.push_back(i + 1);
      if (t[i] == ch) b.push_back(i + 1);
    }
    if (!((int)(a).size()) || !((int)(b).size())) continue;
    long long sum = 0, pre = 0;
    for (int i = (0); i < (((int)(b).size())); ++i) sum += b[i];
    int j = 0;
    for (int i = (0); i < (((int)(a).size())); ++i) {
      while (j < ((int)(b).size()) && b[j] < a[i]) pre += b[j++];
      P += 1ll * pre * (n - a[i] + 1);
      P += 1ll * a[i] * (1ll * (((int)(b).size()) - j) * (n + 1) - (sum - pre));
      if (P >= Q) ret += 1.0 * P / Q, P = 0;
    }
  }
  ret += 1.0 * P / Q;
  return ret;
}
int main() {
  scanf("%d %s %s", &n, s, t);
  printf("%.10f", solve());
  return 0;
}
