#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
//=======================
const int MOD = 1000000007;
const int N = 2e6+13, M = N;
//=======================
vi g[N];
int arr[N];
vi a;
int n, m, k;
//=======================

void solve() {
  int i, j, sx, sy, gx, gy;
  cin >> sx >> sy >> gx >> gy;
  double ans = 1.0 * sy * gx;
  ans += 1.0*gy*sx;
  ans = ans / (1.0*(sy + gy));
  cout << setprecision(10) << fixed;
  cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    while(t--) {
      solve();
    }

    return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for (int i = 0; i < (int)(n) ; i++)
#define rep2(i,a,b) for (int i = (a); i < (int)(b); i++)
#define Rrep(i,n) for (int i = (n); i >= 0; i--)
#define ENDL '\n'
#define SZ(a) (int)(a.size())
#define all(a) a.begin(),a.end()

ll powi(ll x,ll y) { //繰り返し二乗法
    if(y==0) return 1;
    if(y==1) return x;
    if(y%2==1) return x*pow(x,y-1);
    ll rt = pow(x,y/2);
    return rt*rt;
}

ll score(string s, ll n) {
    n++;
    s.at(4) = to_string(n).at(0);
    vector<ll> ci(9,0);
    rep(i,5) ci.at(s.at(i)-'0'-1)++;
    ll ret=0;
    rep(i,9) {
        ret+=(i+1)*powi(10,ci.at(i));
    }
    return ret;
}

int main() {
    cout << fixed << setprecision(20);
    ll k; cin >> k;
    string s, t; cin >> s >> t;

    vector<ll> cards(9,k);
    rep(i,4) cards.at(s.at(i)-'0'-1)--;
    rep(i,4) cards.at(t.at(i)-'0'-1)--;

/*
    ld all = 0;
    rep(i,9) {
        rep(j,9) {
            if (i==j) {
                if(cards.at(i) <2) continue;
                all += cards.at(i)*(cards.at(i)-1);
            }
           else all += cards.at(i)*cards.at(j);
        }
    }
*/
    ld win = 0;

    rep(i,9) {
        rep(j,9) {
            if(cards.at(i) && cards.at(j)) {
                if(score(s,i)>score(t,j)) {
                    win+=cards.at(i)*(cards.at(j)-(i==j));
/*
                    if (i==j) {
                    if(cards.at(i)<2) continue;
                    win += cards.at(i)*(cards.at(i)-1);
                    }
                    else win += cards.at(i)*cards.at(j);
*/
                }
            }
        }
    }

    ll rem=9*k-8;

    cout << win/rem/(rem-1) << endl;
}