#include <bits/stdc++.h>
using namespace std;
long long int n;
long double conteo(vector<int> &a, vector<int> &b) {
  long double amount = 0;
  vector<long double> suma(26, 0);
  for (int i = 0; i < n; i++) {
    suma[b[i]] += i + 1;
    amount += (n - i) * suma[a[i]];
  }
  return amount;
}
long double cuenta(vector<int> &a, vector<int> &b) {
  long double amount = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == b[i]) amount += (n - i) * (i + 1);
  }
  return amount;
}
int main() {
  cout.setf(ios::fixed);
  cout.precision(9);
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    a[i] = c - 'A';
  }
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    b[i] = c - 'A';
  }
  long double suma = conteo(a, b) + conteo(b, a) - cuenta(a, b);
  long double parejas = (n * (n + 1) * (2 * n + 1)) / 6;
  cout << suma / parejas << endl;
}
