#include <bits/stdc++.h>
using namespace std;
int N;
string A, B;
long long SA[26][200000 + 1];
long long SB[26][200000 + 1];
int main() {
  cin >> N >> A >> B;
  long long C = 0;
  for (long long i = N; i >= 1; i--) {
    C += i * i;
  }
  double res = 0;
  for (int i = 0; i < N; i++) {
    for (int c = 0; c < 26; c++) {
      SA[c][i + 1] = SA[c][i];
      SB[c][i + 1] = SB[c][i];
    }
    SA[A[i] - 'A'][i + 1] += (i + 1);
    SB[B[i] - 'A'][i + 1] += (i + 1);
  }
  for (int i = 0; i < N; i++) {
    res += (N - i) * SB[A[i] - 'A'][i + 1] / double(C);
    res += (N - i) * SA[B[i] - 'A'][i] / double(C);
  }
  printf("%.6lf\n", res);
  return 0;
}
