#include <bits/stdc++.h>
using namespace std;
int n;
vector<double> A[26], B[26], cum[26], cum1[26];
char p[200005];
char q[200005];
int search1(long long x, int id) {
  int high = int((A[id]).size()) - 1, low = 1;
  while (low <= high) {
    int mid((high + low) / 2);
    if (A[id][mid] > x)
      high = mid - 1;
    else {
      low = mid + 1;
    }
  }
  return high;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> (p + 1) >> (q + 1);
  for (int i(0), _n(26); i < _n; ++i) {
    A[i].push_back(0);
    B[i].push_back(0);
    cum[i].push_back(0);
    cum1[i].push_back(0);
  }
  for (int i(1), _b(n + 1); i < _b; ++i) {
    A[p[i] - 'A'].push_back(i);
    B[p[i] - 'A'].push_back(n - i + 1);
    cum[p[i] - 'A'].push_back((i));
    cum1[p[i] - 'A'].push_back((n - i + 1));
  }
  for (int i(0), _n(26); i < _n; ++i) {
    for (int j(1), _b(int((A[i]).size())); j < _b; ++j)
      cum[i][j] += cum[i][j - 1];
    for (int j(1), _b(int((A[i]).size())); j < _b; ++j)
      cum1[i][j] += cum1[i][j - 1];
  }
  double ans = 0;
  for (int i(1), _b(n + 1); i < _b; ++i) {
    int id = q[i] - 'A';
    int u = search1(i, id);
    ans += cum[id][u] * (n - i + 1) +
           (cum1[id][int((cum1[id]).size()) - 1] - cum1[id][u]) * (i);
  }
  cout.precision(10);
  cout.setf(ios::fixed);
  cout << 6.0 * ans / n / (1.0 + n) / (2.0 * n + 1);
}
