#include <bits/stdc++.h>
unsigned long long qtde[2][26];
int main(void) {
  int n, i;
  unsigned long long sum[10];
  double ans = 0;
  char a[200001], b[200001];
  scanf("%d", &n);
  scanf("%s%s", a, b);
  memset(sum, 0, sizeof sum);
  for (i = 0; i < n; i++) {
    sum[i % 10] += (n - i) * qtde[1][a[i] - 'A'];
    qtde[0][a[i] - 'A'] += i + 1;
    qtde[1][b[i] - 'A'] += i + 1;
    sum[i % 10] += (n - i) * qtde[0][b[i] - 'A'];
  }
  for (i = 0; i < 10; i++) ans += sum[i] / (double)n;
  ans /= (n + 1);
  ans /= (2 * n + 1);
  ans *= 6;
  printf("%.7lf\n", ans);
  return 0;
}
