#include <bits/stdc++.h>
using namespace std;
static const int INF = 500000000;
template <class T>
void debug(T a, T b) {
  for (; a != b; ++a) cerr << *a << ' ';
  cerr << endl;
}
char s[200005], s2[200005];
vector<int> pos[30], pos2[30];
vector<long long int> Lsum[30], Rsum[30];
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s%s", s, s2);
  for (int i = 0; i < n; ++i) pos[s[i] - 'A'].push_back(i);
  for (int i = 0; i < n; ++i) pos2[s2[i] - 'A'].push_back(i);
  long long int nl = n;
  long long int all = nl * (nl + 1) * (2 * nl + 1) / 6;
  for (int i = 0; i < 26; ++i) {
    Lsum[i].resize(pos2[i].size() + 2);
    Rsum[i] = Lsum[i];
    for (int j = 0; j < pos2[i].size(); ++j) {
      Lsum[i][j] = (j == 0 ? 0 : Lsum[i][j - 1]) + pos2[i][j] + 1;
    }
    for (int j = ((int)pos2[i].size()) - 1; j >= 0; --j) {
      Rsum[i][j] = Rsum[i][j + 1] + (n - pos2[i][j]);
    }
  }
  long double res = 0;
  for (int i = 0; i < 26; ++i) {
    int k = -1;
    for (int j = 0; j < pos[i].size(); ++j) {
      while (k + 1 < (int)pos2[i].size() && pos2[i][k + 1] < pos[i][j]) ++k;
      if (k >= 0) res += Lsum[i][k] * (n - pos[i][j]) / (long double)all;
      if (k + 1 < (int)pos2[i].size())
        res += Rsum[i][k + 1] * (pos[i][j] + 1) / (long double)all;
    }
  }
  printf("%.10f\n", (double)res);
  return 0;
}
