#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n;
string s, e;
vector<int> v[26];
double sum[26][N];
int main() {
  while (cin >> n >> s >> e) {
    for (int i = 0; i < 26; i++) v[i].clear();
    for (int i = 0; i < n; i++) {
      v[e[i] - 'A'].push_back(i);
    }
    double total = 0;
    for (int i = 1; i <= n; i++) {
      total += 1.0 * (n - i + 1) * (n - i + 1);
    }
    for (int i = 0; i < 26; i++) {
      sum[i][0] = 0.0;
      for (int j = 0; j < v[i].size(); j++) {
        sum[i][j + 1] = sum[i][j] + v[i][j] + 1.0;
      }
    }
    double ans = 0.0;
    for (int i = 0; i < n; i++) {
      int c = s[i] - 'A';
      int p = upper_bound(v[c].begin(), v[c].end(), i) - v[c].begin() - 1;
      double t = sum[c][p + 1] * (n - i + 0.0) +
                 ((double)(v[c].size() - p - 1) * (n + 1.0) -
                  (sum[c][v[c].size()] - sum[c][p + 1]) + 0.0) *
                     (i + 1.0);
      ans += t;
    }
    printf("%.10f\n", ans / total);
  }
  return 0;
}
