#include <bits/stdc++.h>
using namespace std;
double sum[2][30][200010];
char A[2][200010];
int main() {
  int N;
  cin >> N;
  cin >> A[0] >> A[1];
  for (int i = 0; i < (N); i++)
    for (int k = 0; k < (2); k++) A[k][i] -= 'A';
  double cont = 0;
  double val = 0;
  for (int i = (1); i <= (N); i++) val = N - i + 1, val *= val, cont += val;
  memset(sum, 0, sizeof(sum));
  for (int i = 0; i < (N); i++) {
    for (int k = 0; k < (2); k++) {
      sum[k][A[k][i]][i] = ((i == 0) ? 0 : sum[k][A[k][i]][i - 1]) + (i + 1);
      if (i > 0) {
        for (char c = 0; c <= 25; c++) {
          sum[k][c][i] = max(sum[k][c][i], sum[k][c][i - 1]);
        }
      }
    }
  }
  double ans = 0;
  for (int i = 0; i < (N); i++) {
    for (int k = 0; k < (2); k++) {
      double* lst = sum[1 - k][A[k][i]];
      double val = lst[i - 1];
      ans += ((double)(N - i)) * val / cont;
    }
    if (A[0][i] == A[1][i]) {
      ans += ((double)(N - i)) * (i + 1) / cont;
    }
  }
  double vv = ans;
  cout << fixed << setprecision(12) << vv << endl;
}
