#include <bits/stdc++.h>
using namespace std;
const int NMAX = 200010, ALPHA = 30;
int N;
long long Sum[ALPHA];
double Ans;
char A[NMAX], B[NMAX];
int main() {
  scanf("%i\n", &N);
  gets(A + 1);
  gets(B + 1);
  long long Posib = (1LL * N * (N + 1) * (2 * N + 1)) / 6;
  for (int i = N; i; --i) {
    int C = B[i] - 'A' + 1;
    Sum[C] += N - i + 1;
    C = A[i] - 'A' + 1;
    Ans += (1LL * i * Sum[C]) / (1.0 * Posib);
  }
  for (int i = 0; i < ALPHA; ++i) Sum[i] = 0;
  for (int i = N; i; --i) {
    int C = B[i] - 'A' + 1;
    Ans += (1LL * i * Sum[C]) / (1.0 * Posib);
    C = A[i] - 'A' + 1;
    Sum[C] += N - i + 1;
  }
  printf("%.9f\n", 1.0 * Ans);
}
