#include <bits/stdc++.h>
using namespace std;
int N;
string sA, sB;
double ans, sumA[30], sumB[30];
long long total;
int main() {
  cin >> N;
  cin >> sA;
  cin >> sB;
  for (int i = 0; i < N; i++) {
    total += ((long long)i + 1) * (i + 1);
    sumA[sA[i] - 'A'] += i + 1;
    ans += (N - i) * (long long)(sumA[sB[i] - 'A'] + sumB[sA[i] - 'A']);
    sumB[sB[i] - 'A'] += i + 1;
  }
  printf("%lf", (double)(ans) / total);
  return 0;
}
