#include <bits/stdc++.h>
using namespace std;
using lint         = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint x, y, a, b;
    cin >> x >> y >> a >> b;
    lint ret = 0;
    for (int i = 0; i <= 60; ++i) {
        bool ok   = true;
        lint tot  = i;
        lint curr = x;
        for (int j = 0; j < i; ++j) {
            if (curr >= y / a) {
                ok = false;
                break;
            }
            curr *= a;
        }
        if (curr > y)
            ok = false;
        lint bs = (y - 1 - curr) / b;
        tot += bs;
        if (!ok)
            continue;
        else
            ret = max(ret, tot);
    }
    cout << ret << "\n";
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;

int main()
{
	ld k;
	cin>>k;
	string s,t;
	cin>>s>>t;
	s.erase(s.end()-1);
	t.erase(t.end()-1);
	vll v(9,k),w1(9,0),w2(9,0);
	for(auto i:s)
	{
		ll a=i-'1';
		v[a]--;
		w1[a]++;
	}
	
	for(auto i:t)
	{
		ll a=i-'1';
		v[a]--;
		w2[a]++;
	}
	
	ld sum=0;
	for(int i=0;i<9;i++)
	{
		for(int j=0;j<9;j++)
		{
			ll a=0,b=0,temp;
			w1[i]++; 
			w2[j]++; 
			
			for(int l=1;l<10;l++)
			{
				a+=l*pow(10,w1[l-1]);
				b+=l*pow(10,w2[l-1]);
			}
			if(a>b)
			{
				temp=v[i];
				v[i]--;
				sum+= temp*v[j];
				v[i]++;
			}
			w1[i]--;
			w2[j]--;
		}
	}
	
	k=9*k-8;
	ld ans=sum/(k*(k-1));
	cout<<ans;
	
	

}