#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
inline int getInt() {
  int x;
  scanf("%d", &x);
  return x;
}
inline long long getLL() {
  long long x;
  scanf("%lld", &x);
  return x;
};
inline int NUM(char c) { return (int)c - 48; }
inline char CHR(int n) { return (char)(n + 48); }
inline void OPEN(const string &s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
int N;
string a, b;
pair<char, pair<int, int> > satu[200005 + 5], dua[200005 + 5];
int ssz, dsz;
long long BITnum[200005 + 5], BITsum[200005 + 5];
inline void add(int x, long long n1, long long n2) {
  for (++x; x <= 200005; x += x & -x) {
    BITsum[x] += n1;
    BITnum[x] += n2;
  }
}
inline long long qnum(int x) {
  long long ret = 0;
  for (++x; x > 0; x -= x & -x) {
    ret += BITnum[x];
  }
  return ret;
}
inline long long qsum(int x) {
  long long ret = 0;
  for (++x; x > 0; x -= x & -x) {
    ret += BITsum[x];
  }
  return ret;
}
int main() {
  cin >> N >> a >> b;
  double ret = 0;
  int awal, akhir;
  long long denom = 0;
  for (int i = (1), _b = (N); i <= _b; i++) {
    denom += (long long)(N - i + 1) * (N - i + 1);
  }
  for (int i = 0, _n = (N); i < _n; i++) {
    satu[ssz++] = make_pair(a[i], make_pair(i + 1, N - (i + 1) + 1));
  }
  for (int i = 0, _n = (N); i < _n; i++) {
    dua[dsz++] = make_pair(b[i], make_pair(i + 1, N - (i + 1) + 1));
  }
  sort(satu, satu + ssz);
  sort(dua, dua + dsz);
  awal = 0, akhir = 0;
  for (int i = 0, _n = (ssz); i < _n; i++) {
    while (akhir < dsz && dua[akhir].first <= satu[i].first) {
      add(dua[akhir].second.second, dua[akhir].second.second, 1);
      akhir++;
    }
    while (awal < dsz && dua[awal].first < satu[i].first) {
      add(dua[awal].second.second, -dua[awal].second.second, -1);
      awal++;
    }
    if (awal >= dsz || dua[awal].first != satu[i].first) continue;
    while (awal < akhir && dua[awal].second.first <= satu[i].second.first) {
      add(dua[awal].second.second, -dua[awal].second.second, -1);
      awal++;
    }
    ret += (double)(qsum(satu[i].second.second) +
                    (qnum(200005) - qnum(satu[i].second.second)) *
                        satu[i].second.second) /
           denom * satu[i].second.first;
  }
  memset(BITsum, 0, sizeof(BITsum));
  memset(BITnum, 0, sizeof(BITnum));
  ssz = dsz = 0;
  swap(a, b);
  for (int i = 0, _n = (N); i < _n; i++) {
    satu[ssz++] = make_pair(a[i], make_pair(i + 1, N - (i + 1) + 1));
  }
  for (int i = 0, _n = (N); i < _n; i++) {
    dua[dsz++] = make_pair(b[i], make_pair(i + 1, N - (i + 1) + 1));
  }
  sort(satu, satu + ssz);
  sort(dua, dua + dsz);
  awal = 0, akhir = 0;
  for (int i = 0, _n = (ssz); i < _n; i++) {
    while (akhir < dsz && dua[akhir].first <= satu[i].first) {
      add(dua[akhir].second.second, dua[akhir].second.second, 1);
      akhir++;
    }
    while (awal < dsz && dua[awal].first < satu[i].first) {
      add(dua[awal].second.second, -dua[awal].second.second, -1);
      awal++;
    }
    if (awal >= dsz || dua[awal].first != satu[i].first) continue;
    while (awal < akhir && dua[awal].second.first < satu[i].second.first) {
      add(dua[awal].second.second, -dua[awal].second.second, -1);
      awal++;
    }
    ret += (double)(qsum(satu[i].second.second) +
                    (qnum(200005) - qnum(satu[i].second.second)) *
                        satu[i].second.second) /
           denom * satu[i].second.first;
  }
  printf("%.10lf\n", ret);
  return 0;
}
