#include <bits/stdc++.h>
using namespace std;
long long n;
char a[1000010], b[1000010];
long long sl[100], sr[100], sum;
void check() {
  long long x = 0;
  for (long long i = 1; i <= n; i++) x += i * (n - i + 1) * (n - i + 1);
  cout << x << endl;
}
int main() {
  memset(sl, 0, sizeof(sl));
  memset(sr, 0, sizeof(sr));
  sum = 0;
  cin >> n;
  long long sum2 = 2 * n + 1, x = 0;
  sum2 = sum2 * (n + 1) * n / 6;
  scanf("%s%s", a, b);
  for (long long i = 0; i < n; i++) sr[b[i]] += n - i;
  for (long long i = 0; i < n; i++) {
    sum += (n - i) * sl[a[i]];
    sum += (i + 1) * sr[a[i]];
    x += sum / sum2;
    sum %= sum2;
    sr[b[i]] -= n - i;
    sl[b[i]] += i + 1;
  }
  printf("%.12lf\n", x + double(sum) / sum2);
  return 0;
}
