#include <bits/stdc++.h>
using namespace std;
int TC, N, t, size;
vector<int> bitstr;
double calc(char c, int n, string a, string b) {
  double res = 0, left = 0, right = 0;
  for (int i = 0; i < (n); i++)
    if (b[i] == c) right += n - i;
  for (int i = 0; i < (n); i++) {
    if (a[i] == c) {
      res += right * (i + 1);
      res += left * (n - i);
    }
    if (b[i] == c) {
      right -= n - i;
      left += i + 1;
    }
  }
  return res;
}
int main() {
  int n;
  string a, b;
  cin >> n;
  cin >> a >> b;
  double ans = 0, sum = 0;
  for (char i = 'A'; i <= 'Z'; i++) ans += calc(i, n, a, b);
  for (int i = 0; i < (n); i++) sum += (i + 1.0) * (i + 1.0);
  printf("%.9f\n", ans / sum);
}
