#include <bits/stdc++.h>
using namespace std;
const int M = 200000 + 10;
vector<int> adj1[30], adj2[30];
double suffix2[M];
double suffix1[M];
int main() {
  time_t t_start, t_end;
  t_start = clock();
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < n; i++) {
    int l1 = s[i] - 'A';
    int l2 = t[i] - 'A';
    adj1[l1].push_back(i);
    adj2[l2].push_back(i);
  }
  double ans = 0;
  for (int i = 0; i < 26; i++) {
    if (!adj1[i].empty() && !adj2[i].empty()) {
      for (int j = adj2[i].size() - 1; j >= 0; j--) {
        if (j == adj2[i].size() - 1) {
          suffix2[j] = n - adj2[i][j];
        } else {
          suffix2[j] = suffix2[j + 1] + n - adj2[i][j];
        }
      }
      for (int j = adj1[i].size() - 1; j >= 0; j--) {
        if (j == adj1[i].size() - 1) {
          suffix1[j] = n - adj1[i][j];
        } else {
          suffix1[j] = suffix1[j + 1] + n - adj1[i][j];
        }
      }
      int sid = 0;
      int eid = 0;
      while (sid < adj1[i].size() && eid < adj2[i].size()) {
        while (eid < adj2[i].size() && adj2[i][eid] <= adj1[i][sid]) {
          ans = ans + (adj2[i][eid] + 1) * suffix1[sid];
          eid++;
        }
        while (eid < adj2[i].size() && sid < adj1[i].size() &&
               adj1[i][sid] < adj2[i][eid]) {
          ans = ans + (adj1[i][sid] + 1) * suffix2[eid];
          sid++;
        }
      }
    }
  }
  double total = 0;
  for (long long int i = 1; i <= n; i++) {
    total = total + i * i;
  }
  ans = ans / total;
  printf("%.10f\n", ans);
  t_end = clock();
  return 0;
}
