#include <bits/stdc++.h>
using namespace std;
char a[200005], b[200005];
long long l_co[200005][26], r_co[200005][26];
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s%s", &a, &b);
  l_co[0][b[0] - 'A'] = 1;
  long long i, j;
  r_co[n - 1][b[n - 1] - 'A'] = 1;
  for (i = 1; i < n; i++) {
    for (j = 0; j < 26; j++) l_co[i][j] = l_co[i - 1][j];
    l_co[i][b[i] - 'A'] += (i + 1);
  }
  for (i = n - 2; i >= 0; i--) {
    for (j = 0; j < 26; j++) r_co[i][j] = r_co[i + 1][j];
    r_co[i][b[i] - 'A'] += (n - i);
  }
  double ans = 0;
  for (i = 0; i < n; i++) {
    ans += (i + 1) * r_co[i][a[i] - 'A'];
    ans += (n - i) * l_co[i][a[i] - 'A'];
    if (a[i] == b[i]) ans -= (n - i) * (i + 1);
  }
  ans /= n;
  ans /= (2 * n + 1);
  ans /= (n + 1);
  ans *= 6;
  printf("%.15f\n", ans);
  return 0;
}
