#include <bits/stdc++.h>
int IntMaxVal = (int)1e20;
int IntMinVal = (int)-1e20;
long long LongMaxVal = (long long)1e20;
long long LongMinVal = (long long)-1e20;
template <typename T>
inline void minimize(T& a, T b) {
  a = std::min(a, b);
}
template <typename T>
inline void maximize(T& a, T b) {
  a = std::max(a, b);
}
using namespace std;
template <typename T>
struct argument_type;
template <typename T, typename U>
struct argument_type<T(U)> {};
template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& s) {
  is >> s.first >> s.second;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (int i = 0; i < v.size(); i++) os << v[i] << ' ';
  os << '\n';
  return os;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& s, pair<T1, T2>& t) {
  s << t.first << ' ' << t.second;
  return s;
}
template <typename T>
vector<T> readVector(int n) {
  vector<T> res(n);
  for (int i = 0; i < n; i++) cin >> res[i];
  return res;
}
int main() {
  srand(time(NULL));
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  ;
  string s1;
  cin >> s1;
  ;
  string s2;
  cin >> s2;
  ;
  auto calc = [n](string& s1, string& s2) {
    double cur = 0;
    vector<long long> right(200);
    for (char c = 'A'; c <= 'Z'; c++)
      if (right[c] != 0) cout << "aAaa";
    for (int i = n - 1; i >= 0; --i) {
      cur += (i + 1) * right[s1[i]];
      right[s2[i]] += n - i;
    }
    for (char c = 'A'; c <= 'Z'; c++)
      if (right[c] < 0) cout << "aAaa";
    if (cur < 0) cout << "aa  --  " << cur << '\n';
    return cur;
  };
  auto r1 = calc(s1, s2);
  auto r2 = calc(s2, s1);
  auto res = r1 + r2;
  for (int i = 0; i < n; ++i)
    if (s1[i] == s2[i]) {
      res += (i + 1) * 1LL * (n - i);
    }
  long long total = 0;
  for (int i = 1; i < n + 1; ++i) {
    total += i * 1LL * i;
  }
  fixed(cout);
  cout << setprecision(9);
  cout << res * 1.0 / total;
}
