#include <bits/stdc++.h>
using namespace std;
const int maxn = 200500;
int n;
string s1, s2;
long long s[maxn];
double get(const vector<int> &a, const vector<int> &b) {
  for (int i = 0; i < (int)(n); i++) {
    s[i] = b[i] ? (i + 1) : 0;
    if (i) s[i] += s[i - 1];
  }
  double res = 0;
  for (int i = 0; i < (int)(n); i++)
    if (i && a[i]) res += s[i - 1] * (n - i);
  return res;
}
void solve() {
  double s = 0;
  vector<int> a(n), b(n);
  for (int I = 0; I < (int)(2); I++) {
    for (char c = 'A'; c <= 'Z'; c++) {
      for (int i = 0; i < (int)(n); i++) a[i] = s1[i] == c;
      for (int i = 0; i < (int)(n); i++) b[i] = s2[i] == c;
      s += get(a, b);
    }
    swap(s1, s2);
  }
  for (int i = 0; i < (int)(n); i++)
    if (s1[i] == s2[i]) s += double(i + 1) * (n - i);
  cout.precision(10);
  cout << fixed;
  cout << (double)s / ((double)n * (n + 1) * (2 * n + 1) / 6.) << endl;
}
int main() {
  cin >> n >> s1 >> s2;
  solve();
  return 0;
}
