#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void chkmin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline void chkmax(T &a, T b) {
  if (a < b) a = b;
}
long long sum[30];
char fir[210000], sec[210000];
int main() {
  int len, i;
  double ans, cnt;
  scanf("%d", &len);
  scanf("%s%s", fir, sec);
  cnt = 1LL * len * (len + 1) * (2 * len + 1) / 6;
  ans = 0;
  memset(sum, 0, sizeof(sum));
  for (i = len - 1; i >= 0; i--) {
    sum[fir[i] - 'A'] += len - i;
    ans += sum[sec[i] - 'A'] * (i + 1) / cnt;
  }
  memset(sum, 0, sizeof(sum));
  for (i = len - 1; i >= 0; i--) {
    ans += sum[fir[i] - 'A'] * (i + 1) / cnt;
    sum[sec[i] - 'A'] += len - i;
  }
  printf("%.15lf\n", 1.0 * ans);
  return 0;
}
