#include <bits/stdc++.h>
using namespace std;
long double tot = 0;
vector<int> ar1[26], ar2[26];
long double ans = 0;
int n;
void solve1(int x) {
  int sz1 = ar1[x].size();
  int sz2 = ar2[x].size();
  long long sum = 0;
  int j = 0;
  for (int i = 0; i < sz1; ++i) {
    while (j < sz2 && ar2[x][j] <= ar1[x][i]) sum += ar2[x][j++];
    ans += tot * (n - ar1[x][i] + 1) * sum;
  }
}
void solve2(int x) {
  int sz1 = ar1[x].size();
  int sz2 = ar2[x].size();
  long long sum = 0;
  int j = 0;
  for (int i = 0; i < sz2; ++i) {
    while (j < sz1 && ar1[x][j] < ar2[x][i]) sum += ar1[x][j++];
    ans += tot * (n - ar2[x][i] + 1) * sum;
  }
}
char tmp[200004];
int main() {
  cin >> n;
  cin >> tmp;
  for (int i = 0; i < n; ++i) ar1[tmp[i] - 'A'].push_back(i + 1);
  cin >> tmp;
  for (int i = 0; i < n; ++i) ar2[tmp[i] - 'A'].push_back(i + 1);
  for (long double i = n, c = 0; i > 0; --i) {
    tot += (i - c) * (i - c);
  }
  tot = tot;
  tot = 1.0 / tot;
  for (int i = 0; i < 26; ++i) solve1(i), solve2(i);
  printf("%.6llf\n", ans);
  return 0;
}
