#include <bits/stdc++.h>
using namespace std;
long long n;
char s1[200010], s2[200010];
double sum2[200010], sum3[200010];
int main() {
  scanf("%I64d", &n);
  scanf("%s%s", s1, s2);
  for (int i = n; i >= 1; i--) s1[i] = s1[i - 1], s2[i] = s2[i - 1];
  double ans = 0;
  for (int i = 0; i <= 25; i++) {
    memset(sum2, 0, sizeof(sum2));
    memset(sum3, 0, sizeof(sum3));
    for (int j = 1; j <= n; j++)
      if (s2[j] == i + 'A')
        sum2[j] += (double)j, sum3[j] += (double)(n + 1 - j);
    for (int j = 1; j <= n; j++) sum2[j] += sum2[j - 1];
    for (int j = n; j >= 1; j--) sum3[j] += sum3[j + 1];
    for (int j = 1; j <= n; j++)
      if (s1[j] == i + 'A') {
        ans += (double)(sum2[j] * (double)(n + 1 - j));
        ans += (double)(sum3[j + 1] * (double)j);
      }
  }
  double sum = (double)n * (double)(n + 1) * (double)(2 * n + 1) / 6.0;
  double fans = ans / sum;
  printf("%.9lf", fans);
  return 0;
}
