#include <bits/stdc++.h>
using namespace std;
long long totj[200000][26];
long long toti[200000][26];
int ctoi(char c) { return int(c - 'A'); }
int main(void) {
  long long n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  double total = 0;
  for (long long i = 1; i <= n; i++) total += (n - i + 1) * (n - i + 1);
  memset(totj, 0, sizeof(totj));
  memset(toti, 0, sizeof(toti));
  totj[0][ctoi(t[0])]++;
  for (long long i = 1; i < n; i++) {
    for (long long j = 0; j < 26; j++) totj[i][j] = totj[i - 1][j];
    totj[i][ctoi(t[i])] += i + 1;
  }
  toti[0][ctoi(s[0])]++;
  for (long long i = 1; i < n; i++) {
    for (long long j = 0; j < 26; j++) toti[i][j] = toti[i - 1][j];
    toti[i][ctoi(s[i])] += i + 1;
  }
  double sum = 0;
  for (long long i = 0; i < n; i++) sum += (n - i) * totj[i][ctoi(s[i])];
  for (long long j = 1; j < n; j++) sum += (n - j) * toti[j - 1][ctoi(t[j])];
  cout.precision(10);
  cout << fixed << sum / total << endl;
  return 0;
}
