#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
const long long linf = 1e18 + 5;
const int N = 2e5 + 5;
int n;
pair<long long, int> dp[N];
char a[N], b[N];
double ans;
int main() {
  cin >> n;
  scanf("%s %s", a + 1, b + 1);
  n = strlen(a + 1);
  for (int i = 'A'; i <= 'Z'; i++) {
    for (int j = 1; j <= n; j++) dp[j] = make_pair(0, 0);
    for (int j = 1; j <= n; j++)
      dp[j] = make_pair(dp[j - 1].first + j * (b[j] == i),
                        dp[j - 1].second + (b[j] == i));
    for (int j = 1; j <= n; j++)
      if (a[j] == i) {
        ans += j * ((double)(n + 1) * (dp[n].second - dp[j].second) -
                    (dp[n].first - dp[j].first));
        ans += (double)(n - j + 1) * dp[j].first;
      }
  }
  ans /= (long long)n * (n + 1) * (2 * n + 1) / 6;
  cout << fixed << setprecision(9) << ans << '\n';
  return 0;
}
