#include <bits/stdc++.h>
using namespace std;
vector<double> h['Z' + 5], S['Z' + 5], In_S['Z' + 5];
int main() {
  int N;
  ios::sync_with_stdio(false);
  string A, B;
  cin >> N;
  cin >> A >> B;
  double tot = 0;
  for (int i = 0; i < N; i++) {
    tot += (double)(N - i) * (double)(N - i);
  }
  for (char i = 'A'; i <= 'Z'; i++) {
    h[i].clear();
    S[i].clear();
    S[i].push_back(0);
    In_S[i].clear();
  }
  double Ans = 0;
  for (int i = 0; i < N; i++) {
    h[B[i]].push_back(i);
    S[B[i]].push_back((double)(i + 1) + S[B[i]][S[B[i]].size() - 1]);
    In_S[B[i]].push_back(N - i);
  }
  for (char i = 'A'; i <= 'Z'; i++) {
    In_S[i].push_back(0);
    for (int j = In_S[i].size() - 2; j >= 0; j--) {
      In_S[i][j] = In_S[i][j + 1] + In_S[i][j];
    }
  }
  for (int i = 0; i < N; i++) {
    int L = lower_bound(h[A[i]].begin(), h[A[i]].end(), i) - h[A[i]].begin();
    Ans += (double)(N - i) * S[A[i]][L] + (double)(i + 1) * In_S[A[i]][L];
  }
  printf("%.9lf\n", double(Ans) / double(tot));
  return 0;
}
