#include <bits/stdc++.h>
using namespace std;
vector<int> adjlist[2][26];
vector<long long> pre[2][26];
long double tot = 0;
void solve1() {
  int cp = 0;
  for (int i = 0; i < 26; i++) {
    int lptr = 0, rptr = 0;
    while (lptr != pre[cp][i].size() && rptr != pre[1 - cp][i].size()) {
      while (rptr != pre[1 - cp][i].size() &&
             adjlist[1 - cp][i][rptr] < adjlist[cp][i][lptr])
        rptr++;
      if (rptr != pre[1 - cp][i].size()) {
        long long ans = pre[1 - cp][i][rptr];
        ans *= adjlist[cp][i][lptr];
        tot += ans;
      }
      lptr++;
    }
  }
}
void solve2() {
  int cp = 1;
  for (int i = 0; i < 26; i++) {
    int lptr = 0, rptr = 0;
    while (lptr != pre[cp][i].size() && rptr != pre[1 - cp][i].size()) {
      while (rptr != pre[1 - cp][i].size() &&
             adjlist[1 - cp][i][rptr] <= adjlist[cp][i][lptr])
        rptr++;
      if (rptr != pre[1 - cp][i].size()) {
        long long ans = pre[1 - cp][i][rptr];
        ans *= adjlist[cp][i][lptr];
        tot += ans;
      }
      lptr++;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n;
  string s;
  cin >> n;
  for (int i = 0; i < 2; i++) {
    cin >> s;
    for (int j = 0; j < s.size(); j++) {
      int ch = s[j] - 'A';
      adjlist[i][ch].push_back(j + 1);
      pre[i][ch].push_back(n - j);
    }
    for (int c = 0; c < 26; c++) {
      if (pre[i][c].size() <= 1) continue;
      for (int j = pre[i][c].size() - 2; j >= 0; j--)
        pre[i][c][j] += pre[i][c][j + 1];
    }
  }
  solve1();
  solve2();
  tot *= 6;
  tot /= (2 * n + 1);
  tot /= (n + 1);
  tot /= n;
  cout.precision(15);
  cout << fixed << tot;
  return 0;
}
