#include <bits/stdc++.h>
using namespace std;
inline int L(int i) { return i << 1; }
inline int R(int i) { return (i << 1) | 1; }
inline int B(int i) { return 1 << i; }
inline int low_bit(int x) { return x & (-x); }
char sa[201000], sb[201000];
long long mat[30][201000], tra[30][201000];
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    double ret = 0;
    scanf("%s%s", sa, sb);
    memset(mat, 0, sizeof(mat));
    memset(tra, 0, sizeof(tra));
    for (int i = 0; i < 26; i++) {
      for (int j = 0; j < n; j++) {
        if (sb[j] - 'A' == i)
          mat[i][j + 1] = mat[i][j] + j + 1;
        else
          mat[i][j + 1] = mat[i][j];
      }
      for (int j = n - 1; j >= 0; j--) {
        if (sb[j] - 'A' == i)
          tra[i][j + 1] = tra[i][j + 2] + n - j;
        else
          tra[i][j + 1] = tra[i][j + 2];
      }
    }
    for (int i = 0; i < 26; i++)
      for (int j = 0; j < n; j++) {
        if (sa[j] - 'A' == i) {
          ret += 1.0 * mat[i][j + 1] * (n - j) + 1.0 * tra[i][j + 1] * (j + 1);
          if (sb[j] - 'A' == i) ret -= 1.0 * (j + 1) * (n - j);
        }
      }
    printf("%.9lf\n", 6.0 * ret / n / (n + 1) / (2 * n + 1));
  }
  return 0;
}
