#include <bits/stdc++.h>
using namespace std;
long long cnt[30], l;
double ans;
char s1[201000], s2[201000];
int main() {
  scanf("%lld", &l);
  double c = l * (l + 1) * (2 * l + 1) / 6.0;
  scanf("%s%s", s1, s2);
  for (long long i = 0; i < l; i++) {
    cnt[s2[i] - 'A'] += i + 1;
    ans += (l - i) * cnt[s1[i] - 'A'] / c;
  }
  memset(cnt, 0, sizeof(cnt));
  for (long long i = l - 1; i >= 0; i--) {
    ans += (i + 1) * cnt[s1[i] - 'A'] / c;
    cnt[s2[i] - 'A'] += l - i;
  }
  printf("%f\n", ans);
  return 0;
}
