#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
int64_t suml[26], sumr[26];
void solve() {
  int N;
  cin >> N;
  int S[N], T[N];
  for (int i = 0; i < N; i++) {
    char x;
    cin >> x;
    S[i] = x - 'A';
  }
  for (int i = 0; i < N; i++) {
    char x;
    cin >> x;
    T[i] = x - 'A';
    sumr[T[i]] += N - i;
  }
  double ans = 0;
  int64_t denom = N * 1LL * (N + 1) * 1LL * (2 * N + 1) / 6;
  for (int i = 0; i < N; i++) {
    ans += double(suml[S[i]] * 1LL * (N - i) + sumr[S[i]] * 1LL * (i + 1)) /
           double(denom);
    sumr[T[i]] -= N - i;
    suml[T[i]] += i + 1;
  }
  cout << fixed << setprecision(12) << ans << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  int tc = 1;
  for (int t = 0; t < tc; t++) solve();
  return 0;
}
