#include <bits/stdc++.h>
using namespace std;
clock_t start;
void Time(bool timeIt) {
  if (!timeIt) return;
  clock_t end = clock();
  double elapsed_time =
      ((long double)end - (long double)start) / (long double)CLOCKS_PER_SEC;
  fprintf(stderr, "Time elapsed = %0.4lf\n", elapsed_time);
}
const int SIZE = 200010;
const int ALPHABET = 26;
char a[SIZE], b[SIZE];
vector<pair<long long, long long> > ps[ALPHABET][2];
int main() {
  start = clock();
  int n;
  scanf("%d %s %s", &n, a, b);
  long long numerator = 0, denominator = 0;
  for (long long i = 1; i <= n; ++i) {
    denominator += 1ll * (n - i + 1) * (n - i + 1);
  }
  for (int i = 0; i < n; ++i) {
    int ch = a[i] - 'A';
    if (ps[ch][0].empty()) {
      ps[ch][0].push_back(make_pair(i + 1, i));
      ps[ch][1].push_back(make_pair(n - i, i));
    } else {
      ps[ch][0].push_back(make_pair(ps[ch][0].back().first + i + 1, i));
      ps[ch][1].push_back(make_pair(ps[ch][1].back().first + n - i, i));
    }
  }
  long double ans = 0;
  for (int i = 0; i < n; ++i) {
    int ch = b[i] - 'A';
    int e = ps[ch][0].size(), s = -1;
    while (e - s > 1) {
      int m = (e + s) >> 1;
      if (ps[ch][0][m].second <= i)
        s = m;
      else
        e = m;
    }
    if (s != -1)
      ans += (long double)(1ll * ps[ch][0][s].first * (n - i)) /
             (long double)denominator;
    e = ps[ch][1].size();
    s = -1;
    while (e - s > 1) {
      int m = (e + s) >> 1;
      if (ps[ch][1][m].second > i)
        e = m;
      else
        s = m;
    }
    if (e != ps[ch][1].size()) {
      long long sum =
          (ps[ch][1].back().first - (s != -1 ? ps[ch][1][s].first : 0));
      ans += (long double)(1ll * sum * (i + 1)) / (long double)denominator;
    }
  }
  printf("%0.10Lf\n", ans);
  Time(true);
  return 0;
}
