#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
#include <cassert>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) ((m).find((a)) != m.end())
#define CONTAINS_SET(m, a) ((m).find((a)) != m.end())
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; exit(0); }
void Yes() { cout << "Yes" << endl; exit(0); }
void No() { cout << "No" << endl; exit(0); }

int K;
int S[10];
int T[10];

signed main()
{
	cin >> K;
	string s;
	string t;
	cin >> s;
	cin >> t;
	for (int i = 0; i < 4; i++)
	{
		S[s[i] - '0']++;
		T[t[i] - '0']++;
	}

	int all = (K * 9 - 8) * (K * 9 - 9);
	int sum = 0;

	for (int i = 1; i <= 9; i++)
	{
		for (int j = 1; j <= 9; j++)
		{
			S[i]++;
			T[j]++;

			int score_i = 0;
			int score_j = 0;
			for (int k = 1; k <= 9; k++)
			{
				int ss = 1;
				for (int l = 0; l < S[k]; l++)
				{
					ss *= 10;
				}
				int tt = 1;
				for (int l = 0; l < T[k]; l++)
				{
					tt *= 10;
				}

				score_i += k * ss;
				score_j += k * tt;
			}

			S[i]--;
			T[j]--;

			if (score_i > score_j)
			{
				if (i == j)
				{
					int rest = K - (S[i] + T[i]);
					int pat = rest * (rest - 1);
					sum += pat;
				}
				else
				{
					int rest_i = K - (S[i] + T[i]);
					int rest_j = K - (S[j] + T[j]);
					sum += rest_i * rest_j;
				}
			}
		}
	}
	
	cout << fixed << setprecision(10);
	cout << (sum / (double)all) << endl;
	//cout << sum << "/" << all << endl;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fly ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define nl "\n"
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;
#define mt make_tuple
#define vec vector
#define ld long double
#define eps 1e-9

#define int long long

const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;

typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

void solve() {

	int n; cin >> n ; 
	int x[n], y[n]; 
	rep(i,0,n) cin >> x[i] >> y[i] ; 

	int ans = 0 ; 
	
	for(int i = 0 ; i < n ; ++i) {
		for(int j = i+1 ; j < n ; ++j) {
			ld slope = (ld)(y[j]-y[i])/(ld)(x[j]-x[i]) ; 
			if(slope >= -1 and slope <= 1) ++ans ; 
		}
	}

	cout << ans ; 
}

int32_t main() {

#ifdef LOCAL
    freopen("error.txt", "w", stderr);
#endif

    fly;
    // int t; cin >> t; while(t--)
        solve() ;

    // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}
