#include <bits/stdc++.h>
using namespace std;
char s1[200010], s2[200010];
vector<int> vet[30];
double suml[30][200010], sumr[30][200010];
int n;
int main() {
  int i, j, k;
  while (scanf("%d", &n) != EOF) {
    scanf("%s%s", s1 + 1, s2 + 1);
    for (i = 0; i < 26; i++) {
      vet[i].clear();
    }
    for (i = 1; i <= n; i++) {
      vet[s2[i] - 'A'].push_back(i);
    }
    for (i = 0; i < 26; i++) {
      sort(vet[i].begin(), vet[i].end());
      suml[i][0] = 0;
      for (j = 0; j < vet[i].size(); j++) {
        suml[i][j + 1] = suml[i][j] + vet[i][j];
      }
      suml[i][vet[i].size() + 1] = 0;
      for (j = vet[i].size() - 1; j >= 0; j--) {
        sumr[i][j + 1] = sumr[i][j + 2] + n - vet[i][j] + 1;
      }
    }
    double res = 0;
    double tot = 0;
    for (i = 1; i <= n; i++) {
      tot += (n - i + 1) * 1.0 * (n - i + 1);
    }
    for (i = 1; i <= n; i++) {
      k = s1[i] - 'A';
      if (vet[k].size() == 0) continue;
      int kk = lower_bound(vet[k].begin(), vet[k].end(), i) - vet[k].begin();
      kk++;
      res += suml[k][kk - 1] * (n - i + 1);
      res += sumr[k][kk] * i;
    }
    printf("%.8f\n", res / tot);
  }
  return 0;
}
