Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya and his friend Vasya play an interesting game. Petya randomly chooses an integer p from the interval [pl, pr] and Vasya chooses an integer v from the interval [vl, vr] (also randomly). Both players choose their integers equiprobably. Find the probability that the interval [min(v, p), max(v, p)] contains exactly k lucky numbers.

The single line contains five integers pl, pr, vl, vr and k (1 ≤ pl ≤ pr ≤ 109, 1 ≤ vl ≤ vr ≤ 109, 1 ≤ k ≤ 1000).

On the single line print the result with an absolute error of no more than 10 - 9.

NoteConsider that [a, b] denotes an interval of integers; this interval includes the boundaries. That is, In first case there are 32 suitable pairs: (1, 7), (1, 8), (1, 9), (1, 10), (2, 7), (2, 8), (2, 9), (2, 10), (3, 7), (3, 8), (3, 9), (3, 10), (4, 7), (4, 8), (4, 9), (4, 10), (7, 1), (7, 2), (7, 3), (7, 4), (8, 1), (8, 2), (8, 3), (8, 4), (9, 1), (9, 2), (9, 3), (9, 4), (10, 1), (10, 2), (10, 3), (10, 4). Total number of possible pairs is 10·10 = 100, so answer is 32 / 100.In second case Petya always get number less than Vasya and the only lucky 7 is between this numbers, so there will be always 1 lucky number.

#include <string>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <sstream>
#include<cmath>
#include<algorithm>
#include<fstream>
#include<cstring>
using namespace std;
# define FOR(i,a,n) for(int i=a;i<n;++i)
# define REP(i,n) FOR(i,0,n)
typedef long long LL;
vector<LL> v;
void calc(int num)
{
	if(num) v.push_back(num);
	if(num*4LL>=1000000000LL) return;
	calc(num*10+4);
	calc(num*10+7);
}
int main()
{
	calc(0);
	LL a,b,c,d,k,den;
	double ans=0;
	cin>>a>>b>>c>>d>>k;
	den=(b-a+1)*(d-c+1);
	v.push_back(0);v.push_back(1000000001);
	sort(v.begin(),v.end());
	int n=v.size();
	for(int i=1,j=k;j<n-1;++i,++j)
	{
		LL x,y,l,h;
		if(a<=v[i]) if(b>v[i-1]) {
		h=min(b,v[i]);
		l=max(v[i-1]+1,a);
		x=h-l+1;
		if(d>=v[j])
		if(c<v[j+1]) {
		y=min(v[j+1]-1,d)-max(v[j],c)+1;
		ans+=x*y*1.0/den;}}
		if(c<=v[i]) if(d>v[i-1]) {
		x=min(d,v[i])-max(v[i-1]+1,c)+1;
		if(b>=v[j])
		if(a<v[j+1]) {
		y=min(v[j+1]-1,b)-max(v[j],a)+1;
		int c=0;
		if(k==1)
		{
			if(v[i]>=a&&v[i]<=b&&v[i]>=c&&v[i]<=d) c=-1;
		}
		ans+=(x*y+c)*1.0/den;}}
	}
	printf("%.9f\n",ans);
}

#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <iostream>
#include <cmath>
#include <sstream>
#include <map>
#include <set>
#include <numeric>
#include <memory.h>
#include <cstdio>
#include <assert.h>

using namespace std;

#define pb push_back
#define INF 1011111111
#define FOR(i,a,b) for (int _n(b), i(a); i < _n; i++)
#define rep(i,n) FOR(i,0,n)
#define ford(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define CL(a,v) memset((a),(v),sizeof(a))
#define mp make_pair
#define X first
#define Y second
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> pii;

int maxn = -(int)1e9;

set<ll> lucky;

void go(ll x)
{
    if(x > maxn) return;
    if(x) lucky.insert(x);
    go(10*x+4), go(10*x+7);
}

ll query(int l, int r, pii p, pii v, int pl, int nv)
{
    pl = max(pl+1, p.X);

    nv = min(nv-1, v.Y);

    l = min(l, p.Y);
    r = max(r, v.X);

    if(l < pl || nv < r) return 0;

    //cout << "query " << l << ' ' << r << ' ' << pl << ' ' << nv << endl;

    return 1LL * (l - pl + 1) * (nv - r + 1);
}

int main()
{
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
	#endif

    pii p,v;
    int k;

    cin >> p.X >> p.Y >> v.X >> v.Y >> k;

    maxn = max(maxn, max(p.Y, v.Y));

    go(0);
    vector<ll> d(all(lucky));

    if(p > v) swap(p,v);

    int pl = -INF;

    ll total = 0;

    for(int i = 0; i + k - 1 < d.size(); i++)
    {
        int l = (int)d[i], r = (int)d[i + k - 1];
        int nv = i+k<d.size() ? d[i+k] : INF;

        //cout << l << ' ' << r << ' ' << nv << endl;

//        if(d[i] >= p.Y && d[i+k-1] <= v.X || d[i] >= v.Y && d[i+k-1] <= p.X)
//        {
//            total = 1LL * (p.Y-p.X+1) * (v.Y-v.X+1);
//            break;
//        }

        total  += query(l,r,p,v,pl,nv);
        total  += query(l,r,v,p,pl,nv);

        //cout << total << endl;

        pl = l;
    }

    if(k == 1)
    {
        rep(i,d.size())
        {
            if(d[i] < p.X || d[i] > p.Y || d[i] < v.X || d[i] > v.Y) continue;

            total --;
        }
    }

    double ans = 1.0 * total / (p.Y-p.X+1) / (v.Y-v.X+1);

    printf("%.10f\n", ans);

	return 0;
}

/*
ID: hamed_51
PROG: ?
LANG: C++
*/

#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <assert.h>
#include <ctime>
#include <bitset>
#include <numeric>
#include <complex>
using namespace std;

#if (_win32 || __win32__)
#define LLD "%i64d"
#else
#define LLD "%lld"
#endif

#define FOREACH(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define FOR(i, a, n) for (register int i = (a); i < (int)(n); ++i)
#define Size(n) ((int)(n).size())
#define all(n) (n).begin(), (n).end()
#define ll long long
#define pb push_back
#define error(x) cout << #x << " = " << x << endl;
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define point complex<double>
//#define X real()
//#define Y imag()
#define X first
#define Y second
#define EPS 1e-3
//#define endl "\n"

inline void read(register int *n) {
	register char c; *n = 0;
	do { c = getchar(); } while (c < '0' || c > '9');
	do { *n = c-'0'+*n*10; c = getchar(); } while (c >= '0' && c <= '9');
}

inline ll common(ll x, ll y, ll xx, ll yy) {
	return max(0LL, min(y, yy)-max(x, xx)+1);
}

vector<ll> lucky;

void gen(ll n) {
	if (n > 1e12) return;
	if (n > 0) lucky.pb(n);
	gen(n*10+4); gen(n*10+7);
}

int main(int argv, char **argc) {
	gen(0);
	lucky.pb(-1);
	sort(all(lucky));
	ll pl, pr, vl, vr, k;
	cin >> pl >> pr >> vl >> vr >> k;
	ll tot = 0;
	FOR(i, k, Size(lucky)-1) {
		tot += common(pl, pr, lucky[i], lucky[i+1]-1)*common(vl, vr, lucky[i-k]+1, lucky[i-k+1]);
		tot += common(vl, vr, lucky[i], lucky[i+1]-1)*common(pl, pr, lucky[i-k]+1, lucky[i-k+1]);
		tot -= common(max(pl, lucky[i]), min(pr, lucky[i+1]-1), max(vl, lucky[i-k]+1), min(vr, lucky[i-k+1]));
	}
	cout << fixed << setprecision(10) << tot/((pr-pl+1.)*(vr-vl+1)) << endl;
	return 0;
}

#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long ll;
int cnt;
ll num[5000];

void genLucky(int dep,ll v) {
	num[cnt++] = v;
	if(dep>=10)return;
	genLucky(dep + 1,v * 10 + 4);
	genLucky(dep + 1,v * 10 + 7);
}

int pl,pr,vl,vr;
int nk;

int getCommon(ll a1,ll b1,ll a2,ll b2) {
	a2 = max(a1,a2);
	b2 = min(b1,b2);
	if(a2 > b2)return 0;
	return b2 - a2 + 1;
}

int main() {
	cnt = 0;
	genLucky(0,0);
	sort(num,num + cnt);
	scanf("%d%d%d%d%d",&pl,&pr,&vl,&vr,&nk);
	ll ans = 0;
	for(int i = 1;i<cnt - 1;i++) {
		int j = i + nk - 1;
		if(j >= cnt - 1)continue;
		if(i==j)  {
			ans += (ll)getCommon(pl,pr,num[i - 1] + 1,num[j + 1] - 1)
						* getCommon(vl,vr,num[i - 1] + 1,num[j + 1] - 1);
			ans -= (ll)getCommon(pl,pr,num[i - 1] + 1,num[i] - 1)
						* getCommon(vl,vr,num[i - 1] + 1,num[i] - 1);
			ans -= (ll)getCommon(pl,pr,num[j] + 1,num[j + 1] - 1)
						* getCommon(vl,vr,num[j] + 1,num[j + 1] - 1);
		} else {
			ans += (ll)getCommon(pl,pr,num[i - 1] + 1,num[i]) * getCommon(vl,vr,num[j],num[j + 1] - 1);
			ans += (ll)getCommon(vl,vr,num[i - 1] + 1,num[i]) * getCommon(pl,pr,num[j],num[j + 1] - 1);
		}
	}
	double pret = (double)ans / (pr - pl + 1) / (vr - vl + 1);
	printf("%.11lf\n",pret);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

long long p1, p2, v1, v2, k, MAX = 1000000000;
vector<long long> a;
double ans;

void get(long long cur) {
    if (cur > MAX) {
        return;
    }
    a.push_back(cur);
    get(cur * 10 + 4), get(cur * 10 + 7);
}

double cnt(long long s, long long e, long long ind) {
    if (ind) {
        if (s > v2 || v1 > e) {
        	return 0;
        }
        return (min(v2, e) - max(v1, s) + 1) / double(v2 - v1 + 1);
    } else {
    	if (s > p2 || p1 > e) {
        	return 0;
        }
        return (min(p2, e) - max(p1, s) + 1) / double(p2 - p1 + 1);
    }
}

void add(long long s, long long e) {
    long long s1 = 0, e1 = MAX;
    if (s) {
    	s1 = a[s - 1] + 1;
    }
    if (e < a.size() - 1) {
    	e1 = a[e + 1] - 1;
    }
    s = a[s], e = a[e];
    ans += cnt(s1, s, 0) * cnt(e, e1, 1), ans += cnt(s1, s, 1) * cnt(e, e1, 0);
    if (s == e && s >= p1 && s <= p2 && s >= v1 && s <= v2) {
        ans -= 1.0 / ((p2 - p1 + 1) * (v2 - v1 + 1));
    }
}

void solve() {
	cin >> p1 >> p2 >> v1 >> v2 >> k;
    get(4), get(7);
    sort(a.begin(), a.end());
    for (long long i = 0; i + k <= a.size(); ++i) {
        add(i, i + k - 1);
    }
    cout.precision(9);
    cout << fixed << ans << '\n';
}

int main() {
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	solve();
    return 0;
}

#include <stdio.h>
#include <algorithm>

using namespace std;

int n, k;
int a[1200];

void gen(int x, int y)
{
	a[n++]=x;
	if (y==9) return;
	gen(x*10+4, y+1);
	gen(x*10+7, y+1);
}

long long cross(int l1, int r1, int l2, int r2)
{
	int l, r;
	l=max(l1, l2);
	r=min(r1, r2);
	if (l>r) return 0;
	else return (long long)(r-l+1);
}

long long cal(int l1, int r1, int l2, int r2)
{
	int i;
	long long v1, v2, res=0;
	for (i=1; i+k<n; i++)
	{
		v1=cross(a[i-1]+1, a[i], l1, r1);
		v2=cross(a[i+k-1], a[i+k]-1, l2, r2);
		long long temp = v1*v2;
		res+=temp;
	}
	return res;
}

int main()
{
	gen(0, 0);
	sort(a, a+n);
	a[n++]=1000000001;

/*
	printf("%d\n", n);
	for (int i=0; i<n; i++)
		printf("%d ", a[i]);
*/

	int l1, r1, l2, r2;
	scanf("%d%d%d%d%d", &l1, &r1, &l2, &r2, &k);
	long long y=(long long)(r1-l1+1)*(long long)(r2-l2+1);
	long long x=cal(l1, r1, l2, r2)+cal(l2, r2, l1, r1);
	if (k==1)
		for (int i=1; i<n-1; i++)
		  if (l1<=a[i] && a[i]<=r1 && l2<=a[i] && a[i]<=r2) x--;
	printf("%.15f\n", (double)x/(double)y);
	return 0;
}

#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    vector<int> lucky(1,0);
    for ( int i = 1; i <= 9; i++ ) {
        for ( int j = 0; j < (1<<i); j++ ) {
            int b = 1, l = 0;
            for ( int k = 0; k < i; k++ ) {
                if ( j&(1<<k) ) {
                    l += 4*b;
                } else {
                    l += 7*b;
                }
                b*=10;
            }
            lucky.push_back(l);
        }
    }
    lucky.push_back(1000000001);
    sort( lucky.begin(), lucky.end() );

    int pl, pr, vl, vr, k;
    cin >> pl >> pr >> vl >> vr >> k;

    double d = 0.0;
    for ( size_t i0 = 1; i0 + k < lucky.size(); i0++ ) {
        int prange = min(pr,lucky[i0]) - max(pl,lucky[i0-1]+1) + 1;
        int vrange = min(vr,lucky[i0+k]-1) - max(vl,lucky[i0+k-1]) + 1;
        if ( prange > 0 && vrange > 0 ) {
            d += 1.0 * prange * vrange;
        }
    }

    for ( size_t i0 = 1; i0 + k < lucky.size(); i0++ ) {
        int vrange = min(vr,lucky[i0]) - max(vl,lucky[i0-1]+1) + 1;
        int prange = min(pr,lucky[i0+k]-1) - max(pl,lucky[i0+k-1]) + 1;
        if ( prange > 0 && vrange > 0 ) {
            d += 1.0 * prange * vrange;
        }
    }

    if ( k == 1 ) {
        for ( size_t i = 1; i < lucky.size()-1; i++ ) {
            if ( pl <= lucky[i] && lucky[i] <= pr && vl <= lucky[i] && lucky[i] <= vr ) {
                d -= 1.0;
            }
        }
    }

    printf( "%.12f\n", d/(pr-pl+1)/(vr-vl+1) );
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define error(x) cout << #x << " = " << x << endl
#define pb push_back
#define sz(a) int(a.size())

typedef long long int64;
typedef pair<int, int> ii;

vector<int> lucky;
int pl, pr, vl, vr, k;
double res;

void dfs(int64 val) {
	if (val > 1e9) return;
	if (val)
		lucky.pb(val);
	dfs(val * 10 + 4);
	dfs(val * 10 + 7);
}

void updateRes(int pl, int pr, int L1, int R1, int vl, int vr, int L2, int R2) {
	int L = max(pl, L1), R = min(pr, R1);
	if (L > R) return;

	double x1 = (double)(R - L + 1) / (pr - pl + 1);

	L = max(vl, L2), R = min(vr, R2);
	if (L > R) return;

	double x2 = (double)(R - L + 1) / (vr - vl + 1);

	res += x1 * x2;
}

int main() {
	// freopen("input.txt", "r", stdin);

	ios::sync_with_stdio(0);
	cin >> pl >> pr >> vl >> vr >> k;

	dfs(0);
	sort(lucky.begin(), lucky.end());
	// error(sz(lucky));

	for (int i = 0; i + k - 1 < sz(lucky); i++) {
		int L = 1, R = 1e9;
		if (i > 0)
			L = lucky[i-1] + 1;
		if (i + k - 1 < sz(lucky) - 1)
			R = lucky[i+k] - 1;
		updateRes(pl, pr, L, lucky[i], vl, vr, lucky[i+k-1], R);
		updateRes(vl, vr, L, lucky[i], pl, pr, lucky[i+k-1], R);

		if (k == 1 && vl <= lucky[i] && lucky[i] <= vr && pl <= lucky[i] && lucky[i] <= pr) {
			res -= 1.0 / (pr - pl + 1) * 1.0 / (vr - vl + 1);
		}
	}

	cout << fixed << setprecision(9) << res << "\n";

	return 0;
}

#include <bits/stdc++.h>
#include <bitset>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(i,j,n) for(int i=j;i<(int)n;i++)
#define all(x) x.begin(),x.end()
#define double long double
#define BUG cerr<<"BUG\n";

typedef long long ll;

using namespace std;

vector<int>arr;
ll overlap(int l1,int r1,int l2,int r2){
    return max(0,min(r1,r2)-max(l1,l2)+1);
}
ll solve(int minL,int minR,int maxL,int maxR,int l1,int r1,int l2,int r2){
    // 1, 2
    ll res=1ll*overlap(minL,minR,l1,r1)*overlap(maxL,maxR,l2,r2);
    // 2, 1
    res+=1ll*overlap(maxL,maxR,l1,r1)*overlap(minL,minR,l2,r2);

    return res;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    REP1(i,1,10){
        REP(msk,1<<i){
            int num=0;
            REP(j,i)
                if((msk>>j)&1)num=num*10+4;
                else num=num*10+7;
            arr.push_back(num);
        }
    }
    sort(all(arr));
    int l1,r1,l2,r2,k;
    cin>>l1>>r1>>l2>>r2>>k;
    ll res=0;
    REP(i,arr.size()){
        int j=i+k-1;
        if(j>=arr.size())continue;
        int minL=i?arr[i-1]+1:1,minR=arr[i];
        int maxL=arr[j],maxR=j+1<arr.size()?arr[j+1]-1:1e9+2;
        if(k==1){
            res+=solve(minL,minR-1,minR,maxR,l1,r1,l2,r2);
            res+=overlap(l1,r1,minR,minR)*overlap(l2,r2,minR+1,maxR);
            res+=overlap(l2,r2,minR,minR)*overlap(l1,r1,minR+1,maxR);
            res+=overlap(l2,r2,minR,minR)*overlap(l1,r1,minR,minR);
        }
        else res+=solve(minL,minR,maxL,maxR,l1,r1,l2,r2);
    }
    cout<<fixed<<setprecision(12)<<1.0*res/(1ll*(r1-l1+1)*(r2-l2+1))<<"\n";
}

//In The Name Of God
//117C by M.D
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long long ld;

const ll Maxn=1e5+7;
const ll Max=1e2+7;
const ll Mod=1e9+7;
const ll Inf=1e5+7;
const ll Const=1000;

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define P_ll pair<ll,ll>
#define P_char pair<char,ll>
#define Sort(a) sort(a.begin(),a.end())

vector<ll>G;
ll C;

void creat_lucky(ll u){
    G.pb(u);
    if(u>C)
        return ;
    creat_lucky(u*10+7);
    creat_lucky(u*10+4);
}

int main(){
    ios_base::sync_with_stdio(false);
    ll v1,v2,p1,p2,k,sum=0;
    cin>>p1>>p2>>v1>>v2>>k;
    C=1e9;
    creat_lucky(0);
    Sort(G);
    ll Size=(p2-p1+1)*(v2-v1+1);
    for(ll i=k;i<G.size()-1;i++){
        ll x1=G[i-k]+1,x2=G[i-k+1],y1=G[i],y2=G[i+1]-1;
        //cout<<x1<<" "<<x2<<" "<<y1<<" "<<y2<<endl;
        sum+=(max(0ll,min(p2,x2)-max(x1,p1)+1))*(max(0ll,min(y2,v2)-max(y1,v1)+1));
        sum+=(max(min(p2,y2)-max(y1,p1)+1,0ll))*(max(min(x2,v2)-max(x1,v1)+1,0ll));
        if(k==1)
            sum-=(max(min(p2,y1)-max(p1,y1)+1,0ll))*(max(min(v2,y1)-max(v1,y1)+1,0ll));
    }
    //cout<<sum<<endl;
    double ans=(double)sum/Size;
    cout<<fixed<<setprecision(12)<<ans<<endl;
    return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int pl,pr,vl,vr,k;
vector<int> lst;
__int64 res;
void gen(__int64 cur)
{
    if (cur>1000000000) return;
    lst.push_back(cur);
    gen(cur*10+4); gen(cur*10+7);

}
pair<int,int> intersect(int a,int b,int c,int d)
{
    if (max(a,c)>min(b,d)) return make_pair(-1,-1); else return make_pair(max(a,c),min(b,d));
}
int main()
{
    cin>>pl>>pr>>vl>>vr>>k;
    gen(0);
    lst.push_back(1000000001);
    sort(lst.begin(),lst.end());
    for (int i=1;i<=lst.size()-k-1;++i)
    {
        pair<int,int> x1=intersect(lst[i-1]+1,lst[i],pl,pr),x2=intersect(lst[i+k-1],lst[i+k]-1,vl,vr);
        pair<int,int> y1=intersect(lst[i-1]+1,lst[i],vl,vr),y2=intersect(lst[i+k-1],lst[i+k]-1,pl,pr);
        if (x1.second!=-1 && x2.second!=-1) res+=(__int64(x1.second)-x1.first+1)*(__int64(x2.second)-x2.first+1);
        if (y1.second!=-1 && y2.second!=-1) res+=(__int64(y1.second)-y1.first+1)*(__int64(y2.second)-y2.first+1);
        if (k==1 && x1.second!=-1 && x2.second!=-1 && y1.second!=-1 && y2.second!=-1) --res;
    }
    printf("%.15lf",res*1.0/(1.0*(pr-pl+1)*(vr-vl+1)));
    return 0;
}

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

vector<long long> goodss;
long long l1, r1, l2, r2, k;

long long leng(long long a, long long b, long long c, long long d)
{
    if(b < c || d < a)
        return 0;
    return min(b, d) - max(a, c) + 1;
}

void gen()
{
    for(int n = 1; n <= 10; n++)
    {
        for(int mask = 0; mask < (1 << n); mask++)
        {
            long long cur = 0;
            for(int j = 0; j < n; j++)
                if(mask & (1 << j))
                    cur = cur * 10 + 4;
                else
                    cur = cur * 10 + 7;
            goodss.push_back(cur);
        }
    }
}

int main()
{
    cin >> l1 >> r1 >> l2 >> r2 >> k;
    gen();
    goodss.push_back(0);
    sort(goodss.begin(), goodss.end());
    long long sz = (r1 - l1 + 1) * (r2 - l2 + 1);
    long long ans = 0;
    for(int i = 1; i < (int)goodss.size() - k; i++)
    {
        long long l = goodss[i];
        long long r = goodss[i + k - 1];
        long long pr = goodss[i - 1];
        long long nxt = goodss[i + k];
        long long loc = leng(pr + 1, l, l1, r1) * leng(r, nxt - 1, l2, r2) + leng(pr + 1, l, l2, r2) * leng(r, nxt - 1, l1, r1);
        if(k == 1 && loc > 0 && leng(l1, r1, l2, r2) > 0)
            loc--;
        ans += loc;
    }
    printf("%.15lf", (double)ans / (double)sz);
}

#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

typedef long long ll;

ll a[10020],l,r,L,R,k,x,y,z;
int c;

void dfs(ll x)
{
	if(x>1e10)
		return;
	a[c++]=x;
	dfs(x*10+4);
	dfs(x*10+7);
}
ll is(ll l,ll r,ll L,ll R)
{
	return max(min(r,R)-max(l,L)+1,0LL);
}
int main()
{
	dfs(0);
	sort(a,a+c);
	cin>>l>>r>>L>>R>>k;
	for(int i=1,j;i+k<c;i++)
	{
		j=i+k;
		x=is(a[i-1]+1,a[i],l,r);
		y=is(a[j-1],a[j]-1,L,R);
		z+=x*y;
		x=is(a[i-1]+1,a[i],L,R);
		y=is(a[j-1],a[j]-1,l,r);
		z+=x*y;
		if(k==1&&l<=a[i]&&a[i]<=r&&L<=a[i]&&a[i]<=R)
			z--;
	}
	printf("%.15lf",1.*z/(r-l+1)/(R-L+1));
	return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
const int INF = 1e9 + 10;

bool ch(int a)
{
    while (a > 0)
    {
        if (a % 10 != 4 && a % 10 != 7)
            return false;
        a /= 10;
    }
    return true;
}
int a[2000], kol = 0;

long long schetl(int l, int r, int d)
{
    if (l > a[d])
        return 0;
    if (r < a[d - 1])
        return 0;
    int k;
    k = min(a[d], r) - max(a[d - 1] + 1, l);
    if (k >= 0)
        return k + 1;
    else
        return 0;
}

long long schetr(int l, int r, int d)
{
    if (r < a[d])
        return 0;
    if (l > a[d + 1])
        return 0;
    int k;
    k = min(a[d + 1] - 1, r) - max(a[d], l);
    if (k >= 0)
        return k + 1;
    else
        return 0;
}

int main()
{
   // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int i, uk = 1, k;
    long long res = 0, x, y, sum, d, zz;
    long long pl, pr, vl, vr;
    cin >> pl >> pr >> vl >> vr >> k;
    for (i = 0; i < 1024; i++)
    {
        x = i;
        d = 0;
        while(x > 1)
        {
            d *= 10;
            if (x % 2 == 0)
                d += 4;
            else
                d += 7;
            x /= 2;
        }
        a[kol] = d;
        kol++;
    }
    a[kol] = INF;
    kol++;
    sort(a, a + kol);
    while (uk + k < kol)
    {
        x = schetl(pl, pr, uk);
        y = schetr(vl, vr, uk + k - 1);
        res += x * y;
        x = schetl(vl, vr, uk);
        y = schetr(pl, pr, uk + k - 1);
        res += x * y;
        uk++;
    }
      for (i = 0; i < kol - 1; i++)
        if (a[i] >= pl && a[i] <= pr && a[i] >= vl && a[i] <= vr && k == 1)
            res--;
    sum = (1 + pr - pl) * (vr - vl + 1);
    cout.precision(15);
    long double z, res1;
    res1 = res;
    z = res1 / sum;
    cout << fixed << z;

    return 0;
}

#include <iostream>
#include <string>
#include <cstring>
#include <string.h>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <bitset>
#include <queue>

using namespace std;

vector <long long> a;
long long pl,pr,vl,vr,k;

void gen(long long cur){
	a.push_back(cur);
	if (cur*10LL+4LL<=2000000000LL)
		gen(cur*10LL+4LL);
	if (cur*10LL+7LL<=2000000000LL)
		gen(cur*10LL+7LL);
}

double prob(int l,int r,int cl,int cr){
	if (cl>r) return 0;
	if (cr<l) return 0;
	int tl=max(l,cl);
	int tr=min(r,cr);
	return (tr-tl+1.0)/(r-l+1.0);
}

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	cin>>pl>>pr>>vl>>vr>>k;

	gen(4);
	gen(7);
	sort(a.begin(),a.end());

	double res=0;

	for (int i=0; i+k-1<a.size(); i++){
		int st=a[i];
		int fi=a[i+k-1];
		if (fi>1000000000) break;
		int dn=1;
		if (i!=0)
			dn=a[i-1]+1;
		int up=1000000000;
		if (i+k<a.size()) up=a[i+k]-1;

		res+=prob(pl,pr,dn,st)*prob(vl,vr,fi,up);
		res+=prob(vl,vr,dn,st)*prob(pl,pr,fi,up);

		if (k==1){
			if (st>=pl&&st<=pr&&st>=vl&&st<=vr)
				res-=1/(double)(pr-pl+1)/(double)(vr-vl+1);
		}
	}

	printf("%.10lf\n",res);

	return 0;
}

#define CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <memory.h>
#include <algorithm>
#include <math.h>
using namespace std;

typedef long long li;
typedef long double ld;
typedef pair <int, int> pi;
typedef pair <li, li> pli;
typedef vector <int> vi;
typedef vector <li> vli;
#define mp make_pair
#define pb push_back
void solve ();
int main ()
{
#ifdef _DEBUG
        freopen ("in.txt", "r", stdin);
#endif
        int t=1;
        while (t--)
                solve ();
        return 0;
}
//caution: is int really int?
#define int li
int p1, p2, v1, v2, k;
int happy[5000];
int t=0;
int pere (pi e, pi r)
{
    if (e>r)
        swap (e, r);
    if (e.second<r.first)
        return 0;
    return min (r.second, e.second)-max(r.first, e.first)+1;
}
vector <pair < pi, int > > q, w;
void solve ()
{
    cin>>p1>>p2>>v1>>v2>>k;
    int p=p2-p1+1;
    int v=v2-v1+1;
    happy[t++]=0;
    for (int i=1; i<=9; i++)
    {
        for (int mask=0; mask<(1<<i); mask++)
        {
            int newnum=0;
            for ( int j=0; j<i; j++ )
                if ( mask & (1<<j) )
                    newnum=newnum*10+7;
                else
                    newnum=newnum*10+4;
            happy[t++]=newnum;
        }
    }
    happy[t++]=1000000001;
    sort (happy, happy+t);
    int ind=0;
    int ans=0;
    for (int i=0; i<t-1; i++)
        if ( happy[i]<p1 && happy[i+1]>=p1 )
        {
            ind=i;
            break;
        }
    for ( int i=ind; i+k<t-1 && happy[i]<=p2; i++ )
    {
        int cur=pere ( mp ( happy[i+k], happy[i+k+1]-1 ), mp (v1, v2) );
       // cout<<"cur=  "<<cur<<endl;
        int z=pere ( mp ( happy[i]+1, happy[i+1]), mp (p1, p2) );
       // cout<<"z= "<<z<<endl;
        ans+=z*cur;
    }
    ind=0;
    for (int i=0; i<t-1; i++)
        if ( happy[i]<v1 && happy[i+1]>=v1 )
        {
            ind=i;
            break;
        }
    for ( int i=ind; i+k<t-1 && happy[i]<=v2; i++ )
    {
        int cur=pere ( mp ( happy[i+k], happy[i+k+1]-1 ), mp (p1, p2) );
        int z=pere ( mp ( happy[i]+1, happy[i+1]), mp (v1, v2) );
        ans+=z*cur;
    }
    if (k==1)
    {
        for (int i=0; i<t; i++)
        {
            int cur=happy[i];
            if (cur>=p1 && cur<=p2 && cur<=v2 && cur>=v1)
                ans--;
        }
    }
    printf ( "%.10Lf", (ld)ans/p/v );
}

#include <bits/stdc++.h>

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

const double pi = 3.141592653589793;

#define xx          first
#define yy          second
#define mp          make_pair
#define intl        long long
#define filein      freopen("input.txt", "r", stdin)
#define fileout     freopen("output.txt", "w", stdout)
#define debug       cout << "YES" << endl
#define what_is(x)  cout << #x << " is " << x << endl
#define pb          push_back
#define pii         pair<int, int>

//find_by_order(int) and order_of_key(int)
//typedef tree < intl , null_type ,less<intl>,rb_tree_tag,tree_order_statistics_node_update > ordered_set;
const int M = 345678;
vector<intl> vec, ara;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    //filein;
    vec.pb(4);
    vec.pb(7);
    int l = 0, r = 1;
    for( int i = 2; i <= 9; i++ )
    {
        for( int j = l; j <= r; j++ )
        {
            intl d = vec[j];
            vec.pb( d*10+4 );
            vec.pb( d*10+7 );
        }
        l = r+1;
        r = vec.size()-1;
    }
    intl pl, pr, vl, vr, k;
    cin >> pl >> pr >> vl >> vr >> k;
    for( int i = 0; i < vec.size(); i++ )
    {
        if( vec[i] >= min(pl, vl) && vec[i] <= max(pr, vr) )
        {
            //cout << vec[i] << " ";
            ara.pb( vec[i] );
        }
    }
    //cout << endl;
    if( ara.size() < k )
    {
        cout << "0.00000000000000" << endl;
        return 0;
    }
    intl ans = 0;
    for( int l = 0; l < ara.size(); l++ )
    {
        int r = l + k-1;
        if( r >= ara.size()  ) break;
        intl prev, nxt;
        if( ara[l] >= pl && ara[r] <= vr )
        {
            if( l == 0 ) prev = pl;
            else prev = max(pl, ara[l-1]+1);
            if( r == ara.size()-1 ) nxt = vr;
            else nxt = min( vr, ara[r+1]-1 );
            if( prev <= pr && nxt >= vl  )
                ans += min( pr-prev+1, ara[l]-prev+1 )*min( nxt - vl+1, nxt- ara[r]+1 );
        }
        //what_is(ans);
        if( ara[l] >= vl && ara[r] <= pr )
        {
            if( l == 0 ) prev = vl;
            else prev = max(vl, ara[l-1]+1);
            if( r == ara.size()-1 ) nxt = pr;
            else nxt = min(pr,ara[r+1]-1);
            if( prev <= vr && nxt >= pl  )
                ans += min( vr-prev+1, ara[l]-prev+1 )*min( nxt - pl+1, nxt- ara[r]+1 );
        }
        //what_is(ans);
    }
    l = max(pl, vl); r = min( pr, vr );
    if( r >= l && k == 1  )
    {
        for( int i = 0; i < ara.size(); i++ )
            if( ara[i] >= l && ara[i] <= r )
                ans--;
    }

    //what_is(ans);
    double sol = (pr-pl+1)*(vr-vl+1);
    sol = ans/sol;
    sol = min( sol, 1.00000000000000000 );
    cout << setprecision(12) << fixed << sol << endl;
    return 0;
}

#include <iostream>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <deque>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second

typedef long long li;
typedef long double ld;

using namespace std;

const ld EPS = 0.000000000001;

vector<li> numb;

void init() {
	numb.pb(0);
	li ch;
	int i, t[20];
	for (i = 0; i < 10; i++)
		t[i] = 0;
	while (t[9] != 1) {
		ch = 0;
		t[0]++;
		i = 0;
		while (t[i] == 3) {
			t[i] = 1;
			t[i+1]++;
			i++;
		}
		for (i = 0; i < 10; i++) {
			if (t[i] == 1)
				ch += 4 * pow((ld) 10, (ld) i);
			if (t[i] == 2)
				ch += 7 * pow((ld) 10, (ld) i);
		}
		numb.pb(ch);
	}
}

int main() {
	cout.precision(15);
	li l1, r1, l2, r2, l3, r3, l4, r4, l5, r5, l6, r6, k, i, n, ans = 0, o1, o2;
	cin >> l1 >> r1 >> l2 >> r2 >> k;
	init();
	n = numb.size();
	for (i = 1; i < n - k; i++) {
		l3 = numb[i-1]+1;
		r3 = numb[i];
		l4 = numb[i+k-1];
		r4 = numb[i+k]-1;
		l5 = max(l1, l3);
		r5 = min(r1, r3);
		l6 = max(l2, l4);
		r6 = min(r2, r4);
		if (r5 == l6)
			ans--;
		if (l5 > r5)
			o1 = 0;
		else
			o1 = r5 - l5 + 1;
		if (l6 > r6)
			o2 = 0;
		else
			o2 = r6 - l6 + 1;
		ans += o1 * o2;
		l5 = max(l1, l4);
		r5 = min(r1, r4);
		l6 = max(l2, l3);
		r6 = min(r2, r3);
		if (l5 > r5)
			o1 = 0;
		else
			o1 = r5 - l5 + 1;
		if (l6 > r6)
			o2 = 0;
		else
			o2 = r6 - l6 + 1;
		ans += o1 * o2;
	}
	cout << (ld)ans / (ld)((r1 - l1 + 1) * (r2 - l2 + 1));
	return 0;
}

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <iomanip>
using namespace std;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long LL;
#define FOR(x, b, e) for(int x=b; x<=(e); ++x)
#define FORD(x, b, e) for(int x=b; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define VAR(v,n) typeof(n) v=(n)
#define ALL(c) c.begin(),c.end()
#define SIZE(x) (int)x.size()
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();++i)
#define PB push_back
#define ST first
#define ND second
#define mp(x,y) make_pair(x,y)

const int N = 100000;
int n;
LL liczby[N];
int pos;

void gen(LL sum){
	if(sum > 10000000000) return ;
	liczby[pos++] = sum;
	gen(sum*10 + 4);
	gen(sum*10 + 7);
}

main(){
	gen(0);
	sort(liczby , liczby + pos);
	LL pl,pr,vl,vr,k;
	cin >> pl >> pr >> vl >> vr >> k;
	if(pl > vl){
		swap(pl,vl);
		swap(pr,vr);
	}
	double wyn = 0;
	int pos = 1, posq = k;
	while(1){
		if(liczby[pos] < pl){ pos++, posq++; }
		else if(liczby[posq] > pr && liczby[posq] > vr) break;
		else{
			// range : [liczby[pos] ; liczby[posq]]
			//cout << "rng : " << liczby[pos] << ' ' << liczby[posq] << endl;
			LL bprzedpocz= max(liczby[pos-1]+1,pl);
			LL bprzedkon = min(liczby[pos],pr);
			LL qprzedpocz= max(liczby[posq],vl);
			LL qprzedkon = min(liczby[posq+1]-1,vr);
			//cout << bprzedpocz << ' ' << bprzedkon << ' ' << qprzedpocz << ' ' <<  qprzedkon << endl;
			if(bprzedkon >= bprzedpocz && qprzedkon >= qprzedpocz)
				wyn += (bprzedkon - bprzedpocz+1)*(qprzedkon - qprzedpocz+1);
			 bprzedpocz= max(liczby[pos-1]+1,vl);
			 bprzedkon = min(liczby[pos],vr);
			 qprzedpocz= max(liczby[posq],pl);
			 qprzedkon = min(liczby[posq+1]-1,pr);
			//cout << bprzedpocz << ' ' << bprzedkon << ' ' << qprzedpocz << ' ' <<  qprzedkon << endl;
			if(bprzedkon >= bprzedpocz && qprzedkon >= qprzedpocz){
				wyn += (bprzedkon - bprzedpocz+1)*(qprzedkon - qprzedpocz+1);
				if(k == 1) wyn--;
			}
			pos++; posq++;
		}
	}
	wyn = wyn / ((vr-vl+1)*(pr - pl+1));
	cout.precision (15); cout << fixed << wyn<<endl;
}

#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

struct luck
{
public:
	luck(): val(0), n(1) {}

	int val, n;

	void next()
	{
		if (val == (1 << n) - 1)
		{
			n++;
			val = 0;
		} else
			val++;
	}

	long long get()
	{
		long long res = 0;
		for(int i = n - 1; i >= 0; i--)
		{
			res *= 10;
			if ((val & (1 << i)) > 0)
				res += 7;
			else
				res += 4;
		}
		return res;
	}
};

int pl, pr, vl, vr, k;
long long a = 1, b = 4, c, d, sum = 0;
luck l, r;

long long calc()
{
	long long A = a;
	if (pl > A)
		A = pl;
	long long B = b;
	if (pr < B)
		B = pr;
	if (A > B)
		return 0;
	long long C = c;
	if (vl > C)
		C = vl;
	long long D = d;
	if (vr < D)
		D = vr;
	if (C > D)
		return 0;
	return (B-A+1) * (D-C+1);
}

long long cross(long long a, long long b, long long c, long long d)
{
	return min(b, d) - max(a, c) + 1;
}

int main(){
	cin >> pl >> pr >> vl >> vr >> k;
	for(int i = 1; i < k; i++)
		r.next();
	for(;;)
	{
		c = r.get();
		r.next();
		d = r.get() - 1;

		if (a > max(pr, vr))
			break;
		sum += calc();
		swap(vl, pl);
		swap(vr, pr);
		sum += calc();
		swap(vl, pl);
		swap(vr, pr);

		if (k == 1 && cross(a, b, pl, pr) > 0 && cross(c, d, vl, vr) > 0 && cross(a, b, vl, vr) > 0 && cross(c, d, pl, pr) > 0)
			sum -= cross(b, c, pl, pr) * cross(b, c, vl, vr);

		a = l.get() + 1;
		l.next();
		b = l.get();
	}
	printf("%.10lf\n", (((long double)sum) / (pr-pl+1)) / (vr-vl+1));
	return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <sstream>

//Hendri's Template
#define REP(i, n) for(int i = 0, _n = (n); i < _n; i++)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, a, b) for(int i = (a), _b = (b); i >= _b; i--)
#define RESET(A,v) memset(A, v, sizeof(A))

#define MP make_pair
#define PB push_back
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

template<class T> inline T MIN(T a, T b){return a < b?a:b;}
template<class T> inline T MAX(T a, T b){return a > b?a:b;}

template<class T> inline void getInt(T& x)
{
	char c;
	int mul = 1;
	while((c = getchar()) != EOF)
	{
		if(c == '-')mul = -1;
		if(c >= '0' && c <= '9')
		{
			x = c-'0';
			break;
		}
	}
	if(c == EOF){x = EOF;return;}
	while(c = getchar())
	{
		if(c >= '0' && c <= '9')
		{
			x = (x<<1)+(x<<3)+(c-'0');
		}
		else break;
	}
	x *= mul;
}
//End of Hendri's Template

ll k,a,b,c,d;
vector<ll> v;

void gen(string s,int l)
{
	if(s.length() == l)
	{
		if(atoll(s.c_str()) < 0)cout << s << endl;
		v.PB(atoll(s.c_str()));
	}
	else
	{
		gen(s+"4",l);
		gen(s+"7",l);
	}
}

int main()
{
	v.PB(0);
	FOR(i,1,12)
	{
		gen("",i);
	}
	sort(v.begin(),v.end());
	getInt(a);getInt(b);getInt(c);getInt(d);
	getInt(k);
	double ok = 0;
	FOR(i,1,v.size()-1)
	{
		int j = i+k-1;
		if(j < v.size())
		{
			if(!(a > v[i] || b <= v[i-1] || c >= v[j+1] || d < v[j]))
			{
				ll lo = MIN(v[i],b)-MAX(v[i-1]+1,a)+1;
				ll hi = MIN(v[j+1]-1,d)-MAX(v[j],c)+1;
				if(lo > 0 && hi > 0)
				{
					ok += 1.0*lo/(b-a+1)*hi/(d-c+1);
				}
			}
			if(!(c > v[i] || d <= v[i-1] || a >= v[j+1] || b < v[j]))
			{
				ll lo = MIN(v[i],d)-MAX(v[i-1]+1,c)+1;
				ll hi = MIN(v[j+1]-1,b)-MAX(v[j],a)+1;
				if(lo > 0 && hi > 0)
				{
					ok += 1.0*lo/(d-c+1)*hi/(b-a+1);
				}
			}
			if(k == 1 && a <= v[i] && b >= v[i] && c <= v[j] && d >= v[j])
			{
				ok -= 1.0/(d-c+1)/(b-a+1);
			}
		}
	}
	printf("%.12f\n",ok);
	return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>

#include<map>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>

typedef long long LL;
#define SI(x) scanf("%d",&x)
#define PI(x) printf("%d\n",x)
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

int pl,pr,vl,vr,k;
vector<int> lucky;

void gen(LL num)
{
	if(num>max(vr,pr)) return;
	if(num!=0)
	{
		if(num>=min(pl,vl)) lucky.PB((int)(num));
	}
	gen(num*10ll+4);
	gen(num*10ll+7);
}

LL ways(int x1,int x2,int y1,int y2,int s,int e,int ok)
{
	int xx1 = x1, xx2 = x2, yy1 = y1, yy2 = y2;
	int t = lucky.size();
	if(s!=0)x1 = max(x1,lucky[s-1]+1);
	x2 = min(x2,lucky[s]);

	if(e!=t-1) y2 = min(y2,lucky[e+1]-1);
	y1 = max(y1,lucky[e]);

	LL ret = 0;
	if(x1>=xx1 && x2<=xx2 && x2>=x1 && y1>=yy1 && y2<=yy2 && y2>=y1)ret=1ll*(x2-x1+1)*(y2-y1+1);
	if(ok && lucky[s]>=x1 && lucky[s]<=x2 && lucky[s]>=y1 && lucky[s]<=y2)ret--;

//	cout<<x1<<" "<<x2<<" "<<y1<<" "<<y2<<" "<<s<<" "<<e<<" "<<ret<<endl;
	return ret;
}

int main()
{
	SI(pl);
	SI(pr);
	SI(vl);
	SI(vr);
	SI(k);
	gen(0);

	double ans = 0.0;

	int s = 0, e = 0, t = lucky.size();

	if(t<k)
	{
		cout<<ans<<endl;
		return 0;
	}
	sort(lucky.begin(),lucky.end());

	/*for(int i=0;i<t;i++)
		cout<<lucky[i]<<endl;
	*/

//	cout<<t<<endl;
	for(int i=0;i<t;i++)
	{
		s = i;
		e = s+k-1;
		if(e>=t) continue;

		if(lucky[s]<min(pl,vl) || lucky[e]>max(vr,pr)) continue;
		if(k==1)
		{
			ans+=ways(pl,pr,vl,vr,s,e,1);
		}
		else ans+=ways(pl,pr,vl,vr,s,e,0);
		ans+=ways(vl,vr,pl,pr,s,e,0);
	}

	ans/=(1.0*(pr-pl+1));
	ans/=(1.0*(vr-vl+1));

//	cout<<ans<<endl;
	printf("%.10lf\n",ans);

	return 0;
}

#include <bits/stdc++.h>
const int N = 2e3+9;
const int inf = 1e9+7;
using namespace std;
using ll = long long;

int num[N], cnt, pl, pr, vl, vr, k;
ll ans = 0;
void dfs(ll s){
    if(s > 1e9) return ;
    if(s) num[cnt++] = s;
    dfs(s*10+4); dfs(s*10+7);
}

ll slove(int L, int l, int r, int R){
    ll res = 0;
    // p <= v
    // printf("%d %d %d %d\n", L, l, r, R);
    res += 1LL*max(min(pr, l)-max(pl, L+1)+1 ,0)*max(min(R-1, vr) - max(vl, r)+1, 0);
    // printf("%lld\n", res);
    // p >= v
    res += 1LL*max(min(vr, l)-max(vl, L+1)+1 ,0)*max(min(R-1, pr) - max(pl, r)+1, 0);
    // printf("%lld\n", res);
    // p == v
    if(l == r && max(pl, vl) <= l && l <= min(pr, vr)) res--;
    // printf("%lld\n", res);
    return res;
}

int main(){
    dfs(0); sort(num, num+cnt);
    scanf("%d%d%d%d%d", &pl, &pr, &vl, &vr, &k);
    for (int i = 0; i <= cnt - k && max(vr, pr) >= num[i+k-1]; i++) {
        ans += slove(i>0?num[i-1]:0, num[i], num[i+k-1], (i+k)<cnt?num[i+k]:inf);
    } return printf("%.12f\n", 1.0*ans/(pr-pl+1)/(vr-vl+1)), 0;
}

#include<stdio.h>
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#define pb push_back
using namespace std;
int p1,p2,v1,v2,k;
vector<int> l;

double prob(int sm, int bg, int st, int dr) {
    if(sm > dr || bg < st) return 0;
    if(bg > dr) bg = dr;
    if(sm < st) sm = st;
    return 1.0*(bg-sm+1) / (dr - st + 1);

}

int main() {
    scanf("%d%d%d%d%d",&p1,&p2,&v1,&v2,&k);
    l.pb(0);
    int oldsz = 0;
    for(int i=1;i<=9;++i) {
        int sz = l.size();
        for(int j=oldsz;j<sz;++j) {
            l.pb(l[j]*10+4);
            l.pb(l[j]*10+7);
        }
        oldsz = sz;
    }
    l.pb(1000000001);
    double rez = 0;
    for(int i=1;i+k<l.size();++i) {
        rez += prob(l[i-1]+1,l[i],p1,p2) * prob(l[i+k-1],l[i+k]-1,v1,v2);
        rez += prob(l[i-1]+1,l[i],v1,v2) * prob(l[i+k-1],l[i+k]-1,p1,p2);
        if(k == 1) {
            rez -= prob(l[i],l[i],p1,p2) * prob(l[i],l[i],v1,v2);
        }
    }
    printf("%.12lf", rez);
    return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>

using namespace std;

int const MAX_P = 1e9;

vector<long long> numbers;

void generate(long long x)
{
    numbers.push_back(x);
    if (x <= MAX_P) {
        generate(x * 10 + 7);
        generate(x * 10 + 4);
    }
}

double get_prob(long long l0, long long r0, long long l1, long long r1)
{
    long long l = max(l0, l1);
    long long r = min(r0, r1);
    if (r < l)
        return 0;
    return 1.0 * (r - l + 1) / (r1 - l1 + 1);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    generate(0);

    sort(numbers.begin(), numbers.end());

#ifdef LOCAL
    cout << "numbers.size() == " << numbers.size() << endl;
#endif

    int pl, pr, vl, vr, k;
    cin >> pl >> pr >> vl >> vr >> k;

    double prob = 0;
    for (int i = 1; i + k < (int) numbers.size(); ++i) {
        prob += get_prob(numbers[i - 1] + 1, numbers[i], pl, pr) * get_prob(numbers[i + k - 1], numbers[i + k] - 1, vl, vr);
        prob += get_prob(numbers[i - 1] + 1, numbers[i], vl, vr) * get_prob(numbers[i + k - 1], numbers[i + k] - 1, pl, pr);
        if (k == 1)
            prob -= get_prob(numbers[i], numbers[i], pl, pr) * get_prob(numbers[i], numbers[i], vl, vr);
    }

    cout << prob << endl;

    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <set>
#include <map>
#include <iomanip>
#include <algorithm>
using namespace std;

typedef long long ll;
vector<ll> nums;

void fill(ll num) {
    if (num > 4444444444LL)
        return;
    nums.push_back(num);
    fill(num * 10 + 4);
    fill(num * 10 + 7);
}

struct segment {
    ll left;
    ll right;
};

ll intersect(segment& s1, segment& s2) {
    ll l = max(s1.left, s2.left);
    ll r = min(s2.right, s1.right);
    if (l > r) return 0;
    return r - l + 1;
}

int main() {
    fill(0);
    sort(nums.begin(), nums.end());
    segment p, v;
    segment q;
    int k;
    cin >> p.left >> p.right >> v.left >> v.right >> k;
    q.left = max(p.left, v.left);
    q.right = min(p.right, v.right);
    bool use_q = q.left <= q.right;
    ll total = (p.right - p.left + 1) * (v.right - v.left + 1);
    ll exact = 0;
    for (int i = 1; i + k - 2 < nums.size(); ++i) {
        int l = i;
        int r = i + k - 1;
        segment left = {nums[i-1]+1, nums[i]};
        segment right = {nums[i+k-1], nums[i+k]-1};
        exact += intersect(left, p) * intersect(right, v);
        exact += intersect(right, p) * intersect(left, v);
        if (use_q && k == 1 && q.left <= nums[i] && q.right >= nums[i])
            --exact;

    }

    cout << setprecision(12) << (double)exact / total;

    return 0;
}

// IN THE NAME OF ALLAH
#include <math.h>
#include <vector>
#include <set>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include<cstring>
#include <cstdlib>
#include <string>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <bitset>

#define int ll

#define F first
#define S second
#define mp make_pair
#define L(x) (2*(x))
#define R(x) ((2*(x))+1)
#define pii pair<int , int>

using namespace std;
typedef long long ll;

const int N = 2e6 + 5 , Mod = 1e9 + 7 , MAXN = 1e8 + 1000 , LG = 30 , M = 1e6 + 5 , P = 727 , Sq = 100;
const ll inf = 3e18 + 10;

vector<int> v;
long double pl, pr, vl, vr, k;

long double check1(long double f1, long double f2){
      if(f2 < pl || f1 > pr)
            return 0;
      f1 = max(f1, pl);
      f2 = min(f2, pr);
      if(f1 > f2)
            return 0;
      long double tt = (f2 - f1 + 1), pp = pr - pl + 1;
      tt /= pp;
      return tt;
}
long double check2(long double f1, long double f2){
      if(f2 < vl || f1 > vr)
            return 0;
      f1 = max(f1, vl);
      f2 = min(f2, vr);
      if(f1 > f2)
            return 0;
      long double tt = (f2 - f1 + 1), pp = vr - vl + 1;
      tt /= pp;
      return tt;
}
int32_t main(){
      ios_base::sync_with_stdio(0); cin.tie(0);
      cin >> pl >> pr >> vl >> vr >> k;
      for(int i = 1; i <= 11; i++){
            for(int j = 0; j < (1 << i); j++){
                  ll ret = 0;
                  for(int x = 0; x < i; x++){
                        if(((1 << x) & j) > 0)
                              ret *= 10, ret += 4;
                        else
                              ret *= 10, ret += 7;
                  }
                  v.push_back(ret);
            }
      }
      sort(v.begin(), v.end());
      long double res = 0;
      for(int i = k - 1; i < (int)v.size() - 1; i++){
            int l2 = v[i - k + 1], l1 = 0;
            if(i == k - 1)
                  l1 = 1;
            else
                  l1 = v[i - k] + 1;
            int r2 = v[i + 1] - 1, r1 = v[i];
            res += check1(l1, l2) * check2(r1, r2);
            res += check2(l1, l2) * check1(r1, r2);
            if(l1 > r1)
                  swap(l1, r1), swap(l2, r2);
            int bad1 = max(l1, r1), bad2 = min(l2, r2);
            if(bad2 < bad1)
                  continue;
            long double fg = vr - vl + 1;
            res -= check1(bad1, bad2)/fg;
      }
      cout << fixed << setprecision(12) << res << endl;
      return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e8+10;
typedef long long ll;
vector<long long>num;
void dfs(ll x){
	num.push_back(x);
	if(x<maxn){
		dfs(x*10+4);
		dfs(x*10+7);
	}
}
void init(){
	dfs(0);
	sort(num.begin(), num.end());
}
int main(){
	init();
	ll pl,pr,vl,vr,k;
	scanf("%lld%lld%lld%lld%lld",&pl,&pr,&vl,&vr,&k);
	int len = num.size();
	ll ans = 0;
	for(int i=1;i<len;i++){
		// printf("num[%d]=%lld\n", i,num[i]);
		if(i+k-1>=len) break;
		if(pl<=num[i]&&vr>=num[i+k-1]){
			if(pr>=num[i-1]&&vl<=num[i+k]){
				ll lc1 = max(pl,num[i-1]+1),rc1 = min(pr,num[i]);
				ll lc2 = max(vl,num[i+k-1]),rc2 = min(vr,num[i+k]-1);
				// printf("lc1 = %lld lc2 = %lld rc1 = %lld rc2 = %lld\n", lc1,lc2,rc1,rc2);
				ans += (rc1-lc1+1)*(rc2-lc2+1);
				// printf("ans = %lld\n", ans);
			}
		}
		if(vl<=num[i]&&pr>=num[i+k-1]){
			if(vr>=num[i-1]&&pl<=num[i+k]){
				ll lc1 = max(vl,num[i-1]+1),rc1 = min(vr,num[i]);
				ll lc2 = max(pl,num[i+k-1]),rc2 = min(pr,num[i+k]-1);
				// printf("lc1 = %lld lc2 = %lld rc1 = %lld rc2 = %lld\n", lc1,lc2,rc1,rc2);
				ans += (rc1-lc1+1)*(rc2-lc2+1);
				// printf("ans = %lld\n", ans);
			}
		}
	}
	for(int i=1;i<len;i++){
		if(num[i]>=pl&&num[i]<=pr&&num[i]<=vr&&num[i]>=vl&&k==1) ans --;
	}
	// printf("ans = %lld\n", ans);
	double d = (pr-pl+1.0)*(vr-vl+1.0);
	printf("%.12f\n", (ans*1.0)/d);
	return 0;
}

#include <stdio.h>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <algorithm>
#define FOR(A, B) for(A=0;A<B;A++)

using namespace std;
vector<long long> luckies;
int l,k;
int lim1,lim2;
void gen(long long c)
{
	if(c > lim2) return;
	if(l > 0 && c >= lim1) luckies.push_back(c);
	l++;
	gen(c*10+4);
	gen(c*10+7);
	l--;
}

int getluckiesin(int s, int e)
{
	int i;
	int ans = 0;
	FOR(i, luckies.size()) {
		if(luckies[i] >= s && luckies[i] <= e) ans++;
	}
	return ans;
}
long long q(int vl, int vr, int pl, int pr, int l1, int l2, int l3, int l4)
{
	int ans = 0;
	int s1 = max(vl, l1);
	long long e1 = min(vr, l2);
	int s2 = max(pl, l3);
	long long e2 = min(pr, l4);
//	printf("computed: %d %d %d %d %d\n", i, s1, e1, s2, e2);
	if(s1 > e1 || s2 > e2) return 0;
	//rintf("advanced: %d %d %d %d %d\n", i, s1, e1, s2, e2);
	return (e1-s1+1)*(e2-s2+1);
}

int main()
{
	int i, j, n, m, pl, pr, vl, vr;
	scanf("%d %d %d %d %d", &vl, &vr, &pl, &pr, &k);
	if(pl < vl) {
		int tmp = pl; pl = vl; vl = tmp;
		tmp = pr; pr = vr; vr = tmp;
	}
	l = 0; lim1=min(vl, pl); lim2 = max(vr, pr);
	luckies.push_back(0);
	gen(0);
	luckies.push_back(1500000000);
	sort(luckies.begin(), luckies.end());
	long long positive = 0;
	int lll = luckies.size()-k+1;
	for(i = 1; i < lll; i++) {
	//	printf("%d\n", luckies[i]);
		positive += q(vl, vr, pl, pr, luckies[i-1]+1, luckies[i], luckies[i+k-1], luckies[i+k]-1);
		positive += q(pl, pr, vl, vr, luckies[i-1]+1, luckies[i], luckies[i+k-1], luckies[i+k]-1);
		if(k == 1) {
			positive -= q(pl, pr, vl, vr, luckies[i], luckies[i], luckies[i], luckies[i]);
		}
	}
	//printf("%lld\n", positive);
	printf("%.10lf\n", (double)positive/(pr-pl+1)/(vr-vl+1));
	return 0;
}

#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    vector<int> lucky(1,0);
    for ( int i = 1; i <= 9; i++ ) {
        for ( int j = 0; j < (1<<i); j++ ) {
            int b = 1, l = 0;
            for ( int k = 0; k < i; k++ ) {
                if ( j&(1<<k) ) {
                    l += 4*b;
                } else {
                    l += 7*b;
                }
                b*=10;
            }
            lucky.push_back(l);
        }
    }
    lucky.push_back(1000000001);
    sort( lucky.begin(), lucky.end() );

    int pl, pr, vl, vr, k;
    cin >> pl >> pr >> vl >> vr >> k;

    double d = 0.0;
    for ( size_t i0 = 1; i0 + k < lucky.size(); i0++ ) {
        int prange = min(pr,lucky[i0]) - max(pl,lucky[i0-1]+1) + 1;
        int vrange = min(vr,lucky[i0+k]-1) - max(vl,lucky[i0+k-1]) + 1;
        if ( prange > 0 && vrange > 0 ) {
            d += 1.0 * prange * vrange;
        }
    }

    for ( size_t i0 = 1; i0 + k < lucky.size(); i0++ ) {
        int vrange = min(vr,lucky[i0]) - max(vl,lucky[i0-1]+1) + 1;
        int prange = min(pr,lucky[i0+k]-1) - max(pl,lucky[i0+k-1]) + 1;
        if ( prange > 0 && vrange > 0 ) {
            d += 1.0 * prange * vrange;
        }
    }

    if ( k == 1 ) {
        for ( size_t i = 1; i < lucky.size()-1; i++ ) {
            if ( pl <= lucky[i] && lucky[i] <= pr && vl <= lucky[i] && lucky[i] <= vr ) {
                d -= 1.0;
            }
        }
    }

    printf( "%.12f\n", d/(pr-pl+1)/(vr-vl+1) );
    return 0;
}

#include<stdio.h>
#include<iostream>
#include<algorithm>
typedef long long ll;
using namespace std;
ll a[10020],l,r,L,R,k,x,y,z;
int c;
using namespace std;
void dfs(ll x)
{
	if(x>1e10)
		return;
	a[c++]=x;
	dfs(x*10+4);
	dfs(x*10+7);
}
ll is(ll l,ll r,ll L,ll R)
{
	return max(min(r,R)-max(l,L)+1,0LL);
}
int main()
{
	dfs(0);
	sort(a,a+c);
	cin>>l>>r>>L>>R>>k;
	for(int i=1,j;i+k<c;i++)
	{
		j=i+k;
		x=is(a[i-1]+1,a[i],l,r);
		y=is(a[j-1],a[j]-1,L,R);
		z+=x*y;
		x=is(a[i-1]+1,a[i],L,R);
		y=is(a[j-1],a[j]-1,l,r);
		z+=x*y;
		if(k==1&&l<=a[i]&&a[i]<=r&&L<=a[i]&&a[i]<=R)
			z--;
	}
	printf("%.15lf",1.*z/(r-l+1)/(R-L+1));
	return 0;
}

#include<bits/stdc++.h>

#define FOR(i,a,b) for(auto i=a; i!=b+1-2*(a>b); i+=1-2*(a>b))
#define REP(i,a,b) for(auto i=a-(a>b); i!=b-(a>b); i+=1-2*(a>b))
#define ALL(v) v.begin(),v.end()
#define mp(a, b) make_pair(a, b)
#define fir first
#define sec second
#define what_is(x) cout<<#x<<" is "<<x<<endl;
#define min3(a,b,c) min(min(a,b),c)
#define max3(a,b,c) max(max(a,b),c)
#define SIZE 100010
#define MAXN 1000000000
#define NUM 1000001
#define PI 3.141592653589793
#define open_read1 freopen("C:\\Users\\Hepic\\Desktop\\a.txt","r",stdin)
#define open_write1 freopen("C:\\Users\\Hepic\\Desktop\\b.txt","w",stdout)
#define open_read freopen("hamming.in","r",stdin)
#define open_write freopen("hamming.out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<int, PII> PIPII;
typedef pair<LL,LL> PLL;

template<typename T, typename T1>
ostream& operator << (ostream &out, pair<T, T1> obj)
{
    return out<<"("<<obj.first<<","<<obj.second<<")";
}

template<typename T, template<typename ELEM, typename ALLOC=allocator<ELEM>> class CONT>
ostream& operator << (ostream &out, CONT<T> cont)
{
    typename CONT<T>::const_iterator itr = cont.begin();
    typename CONT<T>::const_iterator ends = cont.end();

    for(; itr!=ends; ++itr)
        out<<*itr<<" ";
    out<<endl;
}

//#################################################################################################################
//#################################################################################################################
//#################################################################################################################
//#################################################################################################################

LL PL, PR, VL, VR, K, power = 10, cnt_legal, all_prob;
vector<LL> lucky = {4, 7};
int nums[] = {4, 7};
int len, pos, bin = 2, val;
int Tbeg, Tend, dupl;
double res;

int main()
{
    scanf("%I64d%I64d%I64d%I64d%I64d", &PL, &PR, &VL, &VR, &K);

    FOR(t, 1, 9)
    {
        int len = lucky.size();

        REP(i, 0, 2)
            REP(j, pos, len)
                lucky.push_back(nums[i]*power + lucky[j]);

        pos += bin;

        bin *= 2;
        power *= 10;
    }

    Tbeg = 0, Tend = K-1;
    while(Tend < lucky.size())
    {
        if(lucky[Tbeg] >= PL  &&  lucky[Tend] <= VR)
        {
            if(Tbeg > 0)
                val = max(PL, lucky[Tbeg-1]+1);
            else
                val = PL;

//            cout<<"Fir: "<<max(lucky[Tend], VL)<<endl;
            if(lucky[Tend+1]-1 > VL  &&  (!Tbeg || (Tbeg > 0  &&  lucky[Tbeg-1]+1 < PR)))
                cnt_legal += (min(lucky[Tbeg], PR) - val + 1) * (min(VR, lucky[Tend+1]-1) - max(lucky[Tend], VL) + 1);

//            cout<<"s: "<<(min(lucky[Tbeg], PR) - val + 1)<<" "<<(min(VR, lucky[Tend+1]-1) - max(lucky[Tend], VL) + 1)<<endl;
           // cout<<lucky[Tbeg]<<","<<lucky[Tend]<<","<<cnt_legal<<endl;
        }

        if(lucky[Tbeg] >= VL  &&  lucky[Tend] <= PR  &&  (VL != PL  ||  VR != PR  ||  VL != VR))
        {
            if(Tbeg > 0)
                val = max(VL, lucky[Tbeg-1]+1);
            else
                val = VL;

            if(lucky[Tend+1]-1 > PL  &&  (!Tbeg || (Tbeg > 0  &&  lucky[Tbeg-1]+1 < VR)))
                cnt_legal += (min(lucky[Tbeg], VR) - val + 1) * (min(PR, lucky[Tend+1]-1) - max(lucky[Tend], PL) + 1);

           // cout<<lucky[Tbeg]<<" "<<lucky[Tend]<<" "<<cnt_legal<<endl;
        }

        if((lucky[Tbeg] >= VL  &&  lucky[Tend] <= PR  &&  (VL != PL  ||  VR != PR  ||  VL != VR))  &&  K == 1)
            ++dupl;

        ++Tbeg;
        ++Tend;
    }

    all_prob = (VR-VL+1) * (PR-PL+1);
    cnt_legal -= dupl;
    res = (double)cnt_legal / (double)all_prob;

    printf("%.10f\n", res);

    return 0;
}

/*****************/
/* LAM PHAN VIET */
/* Codeforces: D. Lucky Probability
/* Time limit:
/********************************/
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define inpFile(f) freopen(f, "r", stdin)
#define outFile(f) freopen(f, "w", stdout)
#define rep(i, n) for (int i = 0; i < n; i++)
#define fill(ar, val) memset(ar, val, sizeof(ar))
#define PI 3.1415926535897932385
#define uint64 unsigned long long
#define int64 long long
#define all(ar) ar.begin(), ar.end()
#define pb push_back
#define bit(n) (1<<(n))
#define Last(i) ( i & -i )
#define INF 500000000
#define maxN 1000000000

vector<int64> lucky;

void cal(int64 value) {
    if (value < maxN)
        lucky.pb(value);
    if (value >= maxN) return;
    value *= 10;
    cal(value + 4);
    cal(value + 7);
}

int al, ar, bl, br, k;

int get_intersect(int u, int v, int l, int r) {
    u = max(u, l);
    v = min(v, r);
    return (v >= u) ? v - u + 1 : 0;
}

double solve() {
    int64 Count = 0, a, b, c, d;
    for (int i = 0; i < lucky.size(); i++) {
        int j = i + k - 1;
        if (j >= lucky.size()) break;

        a = get_intersect(al, ar, lucky[i - 1] + 1, lucky[i]);
        b = get_intersect(bl, br, lucky[j], lucky[j + 1] - 1);
        Count += a * b;

        c = get_intersect(bl, br, lucky[i - 1] + 1, lucky[i]);
        d = get_intersect(al, ar, lucky[j], lucky[j + 1] - 1);
        Count += c * d;

        if (k == 1 && a && b && c && d) Count--;
    }
    a = ar - al + 1;
    b = br - bl + 1;
    return (double)Count / a / b;
}

int main() {
    #ifndef ONLINE_JUDGE
        inpFile("test.inp"); outFile("test.out");
    #endif
    lucky.pb(-1);
    cal(4); cal(7);
    sort(all(lucky));
    lucky.pb(1000000000);
    scanf("%d %d", &al, &ar);
    scanf("%d %d", &bl, &br);
    scanf("%d", &k);
    printf("%.12lf\n", solve());
    return 0;
}

/* lamphanviet@gmail.com - 2011 */

/*
 * DATE : 2017-07-07
 * Algo :
*/
#include<bits/stdc++.h>
using namespace std;
/*------- Constants---- */

#define LL                      long long
#define Ulong                   unsigned long long
#define FOR(I,A,B)              for(long long i=0; i < n ; i++ )
#define REP(i,n)                for(long long i=0; i < n ; i++ )
#define mp                      make_pair
#define pb                      push_back
#define all(x)                  (x).begin(),(x).end()
#define PI                      acos(-1.0)
#define EPS                     1e-9
#define F                       first
#define S                       second
#define di(x)                   int x; input(x)
#define in(x)                   input(x)
#define in2(x,y)                in(x),in(y)
#define in3(x,y,z)              in(x),in2(y,z)
#define lc                      ((n)<<1)
#define rc                      ((n)<<1|1)
#define db(x)                   cout << #x << " -> " << x << endl;
#define ms(ara_name,value)      memset(ara_name,value,sizeof(ara_name))
#define IO                      ios_base::sync_with_stdio(0);cin.tie(0)
#define READ                    freopen("in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
template<class T> inline void input(T &x)
{
    register char c = getchar();
    x = 0;
    int neg = 0;
    for(; ((c<48 || c>57) && c != '-'); c = getchar());
    if(c=='-')
    {
        neg = 1;
        c = getchar();
    }
    for(; c>47 && c<58 ; c = getchar())
    {
        x = (x<<1) + (x<<3) + c - 48;
    }
    if(neg) x = -x;
}
inline long long bigmod(long long p,long long e,long long M)
{
    long long ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return ret;
}
template <class T> inline T gcd(T a,T b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
template <class T> inline T modinverse(T a,T M)
{
    return bigmod(a,M-2,M);
}

/***************************** END OF TEMPLATE *******************************/

const int N = 1001;
LL A,B,X,Y,K;
vector<LL>vec;
void dfs(long long n)
{
    if(n > 1e10) return ;
    if(n>0) vec.push_back(n);
    dfs(n*10+4);
    dfs(n*10+7);

}

long long func(LL A,LL B,LL X,LL Y)
{
    long long ans = 0;
    for(int i= 0; i < vec.size(); i ++ )
    {
        long long l = (i > 0) ? vec[i-1] + 1 : 1;
        long long r = vec[i];
        l = max(l, A);
        r = min(r, B);

        if(l > B) continue;
        if(l > r) continue;
        int now = i + K - 1;
        if(now == vec.size()) break;
        LL l1 = vec[now];
        LL r1 = (now + 1 <vec.size()) ?  vec[now + 1] - 1 : Y;

        l1 = max(l1, X);
        r1 = min(r1, Y);
        if(l1 > Y ) continue;
        if(l1 > r1) continue;

        //printf("%d %d %d %d\n",l,r,l1,r1);

        ans += (r - l + 1LL) * (r1 - l1 + 1);

    }
    return ans;
}
int main()
{
    cin>>A>>B>>X>>Y>>K;
    dfs(0);
    sort(all(vec));

    long long ans = 0;
    ans += func(A,B,X,Y) + func(X,Y,A,B);
    if(K == 1) {
        int l = max(A,X);
        int r = min(B,Y);
        if(r >= l) ans -= upper_bound(all(vec), r) - lower_bound(all(vec),l);
    }
    printf("%.12lf\n", ans * 1./ (B-A+1) / (Y-X+1));
    return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define maxk 1022
int a[maxk];
//void cal()
//{
//	int a[maxn], num = 2, cnt = 0, i, k, t;
//	a[cnt++] = 4;
//	a[cnt++] = 7;
//	for(i = 2; i <= 9; i++)
//	{
//		t = cnt;
//		for(k = t - num; k <= t - 1; k++)
//		{
//			a[cnt++] = a[k] * 10 + 4;
//			a[cnt++] = a[k] * 10 + 7;
//		}
//		num <<= 1;
//	}
//}

int minusa = 0;
long long calcul(int pl, int pr, int vl, int vr, int k, int i)
{
	    int l1 = max(( i == 0? min(pl, a[i]) : a[i - 1] + 1), pl);
		int r1 = min(a[i], pr);
		int l2 = max(a[i + k - 1] , vl);
		int r2 = min(( i + k == maxk? vr : a[i + k] - 1), vr);

		if(r1 >= l1 && r2 >= l2)
		{
			if(r1 == l2)
			{
				minusa++;
			}
			return (long long)(r1 - l1 + 1)*(r2 - l2 + 1);
		}

		return 0;
}

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

    queue<int> q;
    q.push(4);
    q.push(7);
    int d = 1;
    int cnt = 0;
    while(!q.empty() && d < 10)
    {
    	int size = q.size();
    	while(size--)
    	{
    		int plucky = q.front();
    		a[cnt] = plucky;
    	    q.pop();
    	    if( d < 9)
    	    {
    	    	q.push(plucky*10 + 4);
    	        q.push(plucky*10 + 7);
    	    }
    	    cnt++;
    	}
    	d++;
    }

    //sort(luckies, luckies + cnt);

	int pl, pr, vl, vr, k;
	scanf("%d %d %d %d %d", &pl, &pr, &vl, &vr, &k);

	long long trueSpace = 0;
	for(int i = 0; i <= maxk - k; i++)
	{
	    minusa = 0;
        trueSpace += calcul(pl, pr, vl, vr, k, i);
        trueSpace += calcul(vl, vr, pl, pr, k, i);
        if(minusa == 2)
        {
        	trueSpace--;
        }
	}

	double res = (double)trueSpace/((long long)(pr - pl + 1)*(vr - vl + 1));
	printf("%.13lf", res);
	return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

typedef long long ll;

vector<ll> l;

const ll INF = 1000000000000000000;

ll mini(ll a, ll b)
{
    if (a < b)
        return a;
    return b;
}

ll maxi(ll a, ll b)
{
    if (a > b)
        return a;
    return b;
}

void gen()
{
    l.push_back(0);
    for (int i = 1; i <= 10; ++i)
    {
        for (int j = 0; j < (1 << i); ++j)
        {
            ll a = 0;
            for (int k = 0; k < i; ++k)
            {
                if ((j & (1 << k)) == 0)
                    a = a * 10 + 4;
                else
                    a = a * 10 + 7;
            }
            l.push_back(a);
        }
    }
    l.push_back(INF + 1);
}

ll Prze(ll a, ll b, ll c, ll d)
{
    ll P = maxi(a, c);
    ll K = mini(b, d);
    if (P <= K)
        return K - P + 1;
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);
    ll p1, k1, p2, k2, k;
    cin >> p1 >> k1 >> p2 >> k2 >> k;
    gen();
    sort(l.begin(), l.end());
    ll ileg = 0;
    for (int i = 1; i < l.size() - 1; ++i)
    {
        int j = i + k - 1;
        if (j < l.size() - 1)
        {
            ll L1 = l[i - 1] + 1, P1 = l[i];
            ll L2 = l[j], P2 = l[j + 1] - 1;
            ileg += Prze(L1, P1, p1, k1) * Prze(L2, P2, p2, k2);
            ileg += Prze(L1, P1, p2, k2) * Prze(L2, P2, p1, k1);
            if (k == 1 && l[i] >= p1 && l[i] <= k1 && l[i] >= p2 && l[i] <= k2)
                --ileg;
        }
    }
    ll iled = (k1 - p1 + 1) * (k2 - p2 + 1);
    cout << fixed << setprecision(15);
    cout << (double) ileg / (double) iled;
    return 0;
}

#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>

using namespace std;

#define pb push_back
#define sz(a) (int)a.size()
#define fs first
#define sc second

typedef long long ll;
typedef pair<int,int> ii;

ll p1, p2, v1, v2, st[5000], res;
int k;

void DQ(ll x) {
    if (x > 4444444444LL) return;
    if (x) st[++st[0]] = x;
    DQ(x*10+4); DQ(x*10+7);
}

int main() {
    //freopen("input.txt","r",stdin);
    scanf("%I64d%I64d%I64d%I64d%d",&p1,&p2,&v1,&v2,&k);
    DQ(0);
    sort(st+1,st+st[0]+1);
    ll L = p1;
    while (L <= p2) {
        int s1 = upper_bound(st+1,st+st[0]+1,L)-st;
        ll R = min(st[s1]-1,p2);
        s1--;
        if (s1 < k) {
            L = R+1;
            continue;
        }
        ll L2, R2;
        if (s1 == k) {
            L2 = 0;
            R2 = 3;
        }
        else {
            L2 = st[s1-k];
            R2 = st[s1-k+1]-1;
        }
        if (R2 < v1-1 || L2 > v2-1) {
            L = R+1;
            continue;
        }
        L2 = max(L2,v1-1), R2 = min(R2,v2-1);
        res += (R-L+1)*(R2-L2+1);
        L = R+1;
    }
    L = p1-1;
    while (L <= p2-1) {
        int s1 = upper_bound(st+1,st+st[0]+1,L)-st;
        ll R = min(st[s1]-1,p2-1);
        s1--;
        ll L2, R2;
        if (s1+k >= st[0]) {
            L = R+1;
            continue;
        }
        L2 = st[s1+k];
        R2 = st[s1+k+1]-1;
        L2 = max(L2,v1), R2 = min(R2,v2);
        if (L2 > R2) {
            L = R+1;
            continue;
        }
        res += (R-L+1)*(R2-L2+1);
        L = R+1;
    }
    if (k==1) {
        for (int i = 1; i <= st[0]; ++i)
            if (st[i] >= p1 && st[i] <= p2 && st[i] >= v1 && st[i] <= v2) res--;
    }
    double res2 = res;
    p1 = (p2-p1+1)*(v2-v1+1); double p3 = p1;
    printf("%.10lf\n",min(res2/p3,1.0));
    return 0;
}

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

// io
#define get(i) scanf("%d", &i)
#define flush fflush(stdin)

// manipulations
#define f(i, n) for (int i = 0; i < n; i++)
#define fr(i, n) for (int i = n - 1; i >= 0; i--)
#define ff(i, a, b) for (int i = a; i <= b; i++)
#define lowbit(x) (x & -x)
#define sz(x) int((x).size())

// built-in
#define bitcount __builtin_popcount
#define gcd __gcd

// short
#define pb push_back
#define fill(arr, a) memset(arr, a, sizeof(arr))

// useful bits
#define IN(i, l, r) (l <= i && i <= r)
#define relax(a, b) (a) = max((a), (b))
#define relaxi(a, b) (a) = min((a), (b))

typedef vector<int> VI;
typedef pair<int, int> PII;
typedef long long ll;
typedef long double ld;

ll modpow(ll a, ll b, ll mod = (ll) (1e9 + 7))
{if (!b) return 1; a %= mod; return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod;}

// for rand
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vector<ll> luck;

void genLucky() {
	luck.pb(0); luck.pb(4);

	while (luck.back() < 1e9) {
		ll x = luck.back();
		ll base = 1;
		ll nxt = 0;
		while (x) {
			if (x % 10 == 4) {
				nxt += (x + 3) * base;
				break;
			} else {
				nxt += 4 * base;
				x /= 10;
				if (!x) nxt += 4 * base * 10;
			}
			base *= 10;
		}
		luck.pb(nxt);
	}
}

ll inter(ll a, ll b, ll l, ll r) {
	if (a > b || l > r) return 0;
	else if (a > r || b < l) return 0;
	else if (a > l) return inter(l, r, a, b);
	if (a <= l && r <= b) return r - l + 1;
	return b - l + 1;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	// reads from input and output to output if not ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif

    ll a, b, l, r; int k;

    genLucky();

    while (cin >> a >> b >> l >> r >> k) {
    	ld num = 0;

		ff(i, 1, luck.size() - k) {
			int j = i + k - 1;
			// v in [a, b] <= w in [l, r]
			num += inter(a, b, luck[i-1] + 1, luck[i]) * inter(l, r, luck[j], luck[j+1] - 1);
			// v in [a, b] >= w in [l, r]
			num += inter(l, r, luck[i-1] + 1, luck[i]) * inter(a, b, luck[j], luck[j+1] - 1);

			if (k == 1) num -= inter(l, r, luck[i], luck[i]) * inter(a, b, luck[i], luck[i]);
	    }

	    cout << setprecision(12) << num / (b-a+1) / (r-l+1) << endl;
    }

	return 0;
}

#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <fstream>
#include <math.h>
#include <limits>
#include <set>
#include <map>
#include <sstream>
#include <stdio.h>
#include <time.h>
#include <memory.h>
#include <cassert>
#include <complex>
using namespace std;

vector<int> lucky[9];
vector<int> l1;
int main()
{
    //freopen("in.in","r",stdin);
    int pl,pr,vl,vr,k;
    cin>>pl>>pr>>vl>>vr>>k;
    lucky[0].push_back(4);
    lucky[0].push_back(7);
    for (int i=1;i<9;i++)
    {
        for (int j=0;j<lucky[i-1].size();j++)
        {
            int h=lucky[i-1][j];
            lucky[i].push_back(h*10+4);
            lucky[i].push_back(h*10+7);
        }
    }
    l1.push_back(0);
    for (int i=0;i<9;i++)
        for (int j=0;j<lucky[i].size();j++)
            l1.push_back(lucky[i][j]);
    l1.push_back(1000000001);
    double ver=0;
    int cnt=0;
    while (pl>l1[cnt]) cnt++;
    int i1=pr-pl+1,i2=vr-vl+1;
    for (int i=cnt-1;l1[i]<=pr;i++)
    {
        int lv1,rv1,lv2,rv2;
        lv1=max(pl,l1[i]+1);
        rv1=min(pr,l1[i+1]-1);
        lv2=max(pl,l1[i+1]);
        rv2=min(pr,l1[i+1]);
        if (i+k+1<l1.size())
        {
            int ll1=l1[i+k];
            int rr1=l1[i+k+1]-1;
            ll1=max(ll1,vl);
            rr1=min(rr1,vr);
            if (rr1>=ll1)
                ver+=((double)(max(0,rv1-lv1+1))/i1)*((double)(rr1-ll1+1)/i2);
        }
        if (i-k>=0)
        {
            int ll1=l1[i-k]+1;
            int rr1=l1[i-k+1];
            ll1=max(ll1,vl);
            rr1=min(rr1,vr);
            if (rr1>=ll1)
                ver+=((double)(max(0,rv1-lv1+1))/i1)*((double)(rr1-ll1+1)/i2);
        }
        if (lv2==rv2)
        {
            int ll1,rr1,ll2,rr2;
            ll1=ll2=0;
            rr1=rr2=-1;
            if (i+k+1<l1.size())
            {
                ll1=l1[i+k];
                rr1=l1[i+k+1]-1;
                ll1=max(ll1,vl);
                rr1=min(rr1,vr);
            }
            if (i-k+1>=0)
            {
                ll2=l1[i-k+1]+1;
                rr2=l1[i-k+2];
                ll2=max(ll2,vl);
                rr2=min(rr2,vr);
            }
            if (rr2==ll1) rr2--;
            ver+=(1.0/i1)*((double)(max(rr1-ll1+1,0)+max(rr2-ll2+1,0))/i2);
        }
    }
    printf("%.10lf",ver);
    return 0;
}

#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <list>
#include <cstring>
#include <stack>
#include <bitset>

using namespace std;

#define NMAX 2147483647
#define LMAX 9223372036854775807LL
#define pb push_back
#define pob pop_back
#define mp make_pair
#define st first
#define nd second
#define LB lower_bound
#define NP next_permutation
#define BS binary_search
#define SZ(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i,a,b) for(int i=(a);i>(b);--i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,1,n)
#define ALL(z) z.begin(),z.end()
#define TR(c,it) for(typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
//int dd[] = {31,28,31,30,31,30,31,31,30,31,30,31};

template<class T> T gcd(T a,T b) { return (b==0)?a:gcd(b,a%b); }
template<class T> T lcm(T a,T b) { return a*(b/gcd(a,b)); }
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> ii;
typedef vector<ii> vii;

using namespace std;

vector <long long> L;
map <long long, bool> mapa;

void go(long long now)
{
  if(now > 1000000000LL) return;
  if(now > 0 && mapa[now] == 0)
  {
    L.pb(now);
  }
  go(now * 10LL + 4LL);
  go(now * 10LL + 7LL);
}

int main()
{
  go(0);
  sort(L.begin(), L.end());
  int len = L.size();
  long long p1, pr, v1, vr, k;
  while(cin >> p1 >> pr >> v1 >> vr >> k)
  {
    long long tot = 0;
    for(int i = 0; i < len - k + 1; i++)
    {
      long long awal = L[i];
      long long akhir = L[i+k-1];
      long long temp = 0;
      if(p1 <= awal && akhir <= vr)
      {
        if(i) temp = min(awal, pr) - max(p1, L[i-1] + 1LL) + 1LL;
        else temp = min(awal, pr) - p1 + 1LL;
        if(i + k < len && temp > 0) temp *= (min(vr, L[i+k] - 1LL) - max(v1, L[i+k-1]) + 1LL);
        else temp *= (vr - max(v1, L[i+k-1]) + 1LL);
      }
      swap(p1, v1); swap(pr, vr);
      if(temp > 0) tot += temp;
      temp = 0;
      if(p1 <= awal && akhir <= vr)
      {
        if(i) temp = min(awal, pr) - max(p1, L[i-1] + 1LL) + 1LL;
        else temp = min(awal, pr) - p1 + 1LL;
        if(i + k < len && temp > 0) temp *= (min(vr, L[i+k] - 1LL) - max(v1, L[i+k-1]) + 1LL);
        else temp *= (vr - max(v1, L[i+k-1]) + 1LL);
        if(temp > 0 && k == 1) temp--;
      }
      if(temp > 0) tot += temp;
      swap(p1, v1); swap(pr, vr);
    }
    double ans = (double)tot/(double)(vr - v1 + 1LL)/(double)(pr - p1 + 1LL);
    printf("%.9lf\n",ans);
  }
  return 0;
}

#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int p1,p2,v1,v2,k;
	scanf("%d%d%d%d%d",&p1,&p2,&v1,&v2,&k);
	vector<int> luckies;
	luckies.push_back(0);
	luckies.push_back(4);
	luckies.push_back(7);
	for(int i = 2; i <= 9;i ++){
		for(int j = 0;j < (1<<i);j ++){
			int val = 1,res = 0;
			for(int k = 0;k < i;k ++){
				if(j&(1<<k)){
					res += 7 * val;
				} else {
					res += 4 * val;
				}
				val *= 10;
			}
			luckies.push_back(res);
		}
	}
	luckies.push_back(1000000001);
	long long ans = 0;
	for(int i = 1; i + k - 1 < luckies.size() - 1;i ++){
		// includes i and i+k-1
		int minl2 = luckies[i-1], maxl2 = luckies[i+k];
		int minl = luckies[i], maxl = luckies[i+k-1];
		// minv2 < p <= minv and maxv <= v < maxv2
		{
			int minp = max(minl2+1, p1);
			int maxp = min(minl, p2);
			int minv = max(maxl, v1);
			int maxv = min(maxl2-1, v2);
			if(minp <= maxp && minv <= maxv) {
				ans += (maxp-minp+1) * (long long )(maxv-minv+1);
			}
		}
		{
			int minv = max(minl2+1, v1);
			int maxv = min(minl, v2);
			int minp = max(maxl, p1);
			int maxp = min(maxl2-1, p2);
			if(minp <= maxp && minv <= maxv) {
				ans += (maxp-minp+1) * (long long )(maxv-minv+1);
			}
		}
		if(k == 1) {
			if(p1 <= luckies[i] && luckies[i] <= p2 && v1 <= luckies[i] && luckies[i] <= v2){
				ans --;
			}
		}
	}
	printf("%.20f\n",ans / (double)((long long)(p2-p1+1) * (long long)(v2-v1+1)));
	return 0;
}

//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
//assert(q==w) если q!=w --> runtime error
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int>> matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};

vector<ll>lucky;

void f(ll v){
    if(v>10000000000){
        return;
    }
    lucky.pb(v);
    f(v*10+4);
    f(v*10+7);
}

ll intersect(ll l,ll r,ll l1,ll r1){
    if(l>r1 || l1>r){
        return 0;
    }
    if(l1<=l && r<=r1){
        return r-l+1;
    }
    if(l<=l1 && r1<=r){
        return r1-l1+1;
    }
    if(l1<=r && r<=r1){
        return r-l1+1;
    }
    if(l<=r1 && r1<=r){
        return r1-l+1;
    }
}
int main(){
    boost();
    f(4);
    f(7);
    sort(all(lucky));
    ll x,y,x1,y1,k;
    cin>>x>>y>>x1>>y1>>k;
    ld cntr=0;
    for(ll i=0;i+k<lucky.size();i++){
        if(i+k-1>lucky.size()-1){
            continue;
        }
        ll q=0;
        if(i>=1){
            q=intersect(x,y,lucky[i-1]+1,lucky[i]);
        }
        else{
            q=intersect(x,y,0,lucky[i]);
        }
        ll q1=0;
        ll j=i+k-1;
        if(j<=lucky.size()-1){
            q1=intersect(x1,y1,lucky[j],lucky[j+1]-1);
        }
        else{
            q1=intersect(x1,y1,lucky[j],linf);
        }
        if(q1<0 || q<0){
            continue;
        }
        cntr+=q*q1;
    }
    swap(x,x1);
    swap(y,y1);
    for(ll i=0;i<lucky.size();i++){
        if(i+k-1>lucky.size()-1){
            continue;
        }
        ll q=0;
        if(i>=1){
            q=intersect(x,y,lucky[i-1]+1,lucky[i]);
        }
        else{
            q=intersect(x,y,0,lucky[i]);
        }
        ll q1=0;
        ll j=i+k-1;
        if(j<=lucky.size()-1){
            q1=intersect(x1,y1,lucky[j],lucky[j+1]-1);
        }
        else{
            q1=intersect(x1,y1,lucky[j],linf);
        }
        if(q1<0 || q<0){
            continue;
        }
        cntr+=q*q1;
    }
    if(k==1){
		for(int i=0;i<lucky.size();i++) {
			cntr-=intersect(lucky[i],lucky[i],x,y)*intersect(lucky[i],lucky[i],x1,y1);
		}
	}
    ld Q=(y-x+1)*(y1-x1+1);
    cout<<fixed<<setprecision(9)<<cntr/Q;
	exit(0);
}

#include <stdio.h>
#include <algorithm>

using namespace std;

int n, k;
int a[1200];

void gen(int x, int y)
{
	a[n++]=x;
	if (y==9) return;
	gen(x*10+4, y+1);
	gen(x*10+7, y+1);
}

long long cross(int l1, int r1, int l2, int r2)
{
	int l, r;
	l=max(l1, l2);
	r=min(r1, r2);
	if (l>r) return 0;
	else return (long long)(r-l+1);
}

long long cal(int l1, int r1, int l2, int r2)
{
	int i;
	long long v1, v2, res=0;
	for (i=1; i+k<n; i++)
	{
		v1=cross(a[i-1]+1, a[i], l1, r1);
		v2=cross(a[i+k-1], a[i+k]-1, l2, r2);
		long long temp = v1*v2;
		res+=temp;
	}
	return res;
}

int main()
{
	gen(0, 0);
	sort(a, a+n);
	a[n++]=1000000001;

/*
	printf("%d\n", n);
	for (int i=0; i<n; i++)
		printf("%d ", a[i]);
*/

	int l1, r1, l2, r2;
	scanf("%d%d%d%d%d", &l1, &r1, &l2, &r2, &k);
	long long y=(long long)(r1-l1+1)*(long long)(r2-l2+1);
	long long x=cal(l1, r1, l2, r2)+cal(l2, r2, l1, r1);
	if (k==1)
		for (int i=1; i<n-1; i++)
		  if (l1<=a[i] && a[i]<=r1 && l2<=a[i] && a[i]<=r2) x--;
	printf("%.15f\n", (double)x/(double)y);
	return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#define ll long long
using namespace std;
const int INF = 1000000001;

vector <int> v;
int lucky[2] = {4, 7};
int pl, pr, ql, qr, k;

ll esh(ll al, ll ar, ll bl, ll br){
	ll mn = max(al, bl);
	ll mx = min(ar, br);
	if (mx < mn) return 0;
	else return mx - mn + 1;
}

bool in(ll x, ll al, ll ar){
     return x <= ar && x >= al;
}

ll seg(ll al, ll ar, ll bl, ll br){
	ll ans = 0;
	ans += esh(al, ar, pl, pr) * esh(bl, br, ql, qr);
	ans += esh(al, ar, ql, qr) * esh(bl, br, pl, pr);
	if (ar == bl && in(ar, pl, pr) && in(bl, ql, qr)) ans--;//here is the bug for k == 1 :-s
    //cout << ans << endl;
	return ans;
}

int main()
{
	cin >> pl >> pr >> ql >> qr >> k;

	for (int i = 1;i < 10;++i){
		for (int j = 0;j < (1 << i);++j){
			int ans = 0;
			for (int l = 0;l < i;++l)
				ans = ans * 10 + lucky[(j >> l) & 1];
			v.push_back(ans);
		}
	}
	v.push_back(-1);
	v.push_back(INF);
	sort(v.begin(), v.end());
	ll s = 0;
	for (int i = 1;i + k < v.size();++i){
        s += seg(v[i - 1] + 1, v[i], v[i + k - 1], v[i + k] - 1);
	}

	double p = s / (double)((ll)(pr - pl + 1) * (ll)(qr - ql + 1));
	printf("%.11lf\n", p);
	cin >> k;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
using namespace __gnu_pbds;
#define _for(i,a,b) for(int i=(a);i<(b);++i)
#define ms(a) memset(a,0,sizeof(a))
#define ms_inf(a) memset(a,0x3f,sizeof(a))
#define ms_ninf(a) memset(a,0xcf,sizeof(a))
#define pb push_back
#define mp make_pair
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define lc (o<<1)
#define rc (o<<1|1)
//#include<ext/pb_ds/priority_queue.hpp>
//typedef __gnu_pbds::priority_queue<no> heap;  //��ƫ��
typedef long long ll;
typedef unsigned long long ull;
ull MOD=212370440130137957ll;
int mod=1e9+7;
ll INF=1e18;
const int maxn=1010;
const int maxl=1e3+10;
const double PI=acos(-1.0);
const double eps=1e-8;
mt19937_64 rng((ull)(new char));
ll w[2]={4,7};
vector<ll>lucky;
void gen(int r)
{
	_for(i,0,1<<r)
	{
		ll u=0;ll ten=1;
		_for(t,0,r)
		{
			int e=((i>>t)&1);
			u+=w[e]*ten;
			ten*=10;
		}
		lucky.pb(u);
	}
}
void genall()
{
	_for(i,1,12)gen(i);auto&e=lucky;e.pb(0);
	sort(e.begin(),e.end());
}
struct in
{
	ll l,r;
	void inp()
	{
		cin>>l>>r;
	}
	ll len()
	{
		return r-l+1;
	}
};
int k;
ll inter(in a,in b)
{
	return max(0ll,min(a.r,b.r)-max(a.l,b.l)+1);
}
ll solve(in p,in q)
{
	genall();
	auto&e=lucky;ll ans=0;
	_for(t,1,e.size())
	{
		int ri=t+k-1;
		if(ri+1>=e.size())break;
		in L={e[t-1]+1,e[t]};
		in R={e[ri],e[ri+1]-1};
		//p<=q
		ans+=inter(p,L)*inter(q,R);
		//q>=q
		ans+=inter(p,R)*inter(q,L);
		//-p==q
		if(k==1&&inter(p,L)*inter(q,R)&&inter(p,R)*inter(q,L))
		{
			--ans;
		}
	}
	return ans;
}
ll tot(in p,in v)
{
	return p.len()*v.len();
}
int main()
{
	fast;in p,v;p.inp(),v.inp();cin>>k;
	printf("%.12lf",(double)solve(p,v)/tot(p,v));
}

#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <list>
#include <cstring>
#include <stack>
#include <bitset>

using namespace std;

#define NMAX 2147483647
#define LMAX 9223372036854775807LL
#define pb push_back
#define pob pop_back
#define mp make_pair
#define st first
#define nd second
#define LB lower_bound
#define NP next_permutation
#define BS binary_search
#define SZ(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i,a,b) for(int i=(a);i>(b);--i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,1,n)
#define ALL(z) z.begin(),z.end()
#define TR(c,it) for(typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
//int dd[] = {31,28,31,30,31,30,31,31,30,31,30,31};

template<class T> T gcd(T a,T b) { return (b==0)?a:gcd(b,a%b); }
template<class T> T lcm(T a,T b) { return a*(b/gcd(a,b)); }
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> ii;
typedef vector<ii> vii;

using namespace std;

vector <long long> L;
map <long long, bool> mapa;

void go(long long now)
{
  if(now > 1000000000LL) return;
  if(now > 0 && mapa[now] == 0)
  {
    L.pb(now);
  }
  go(now * 10LL + 4LL);
  go(now * 10LL + 7LL);
}

int main()
{
  go(0);
  sort(L.begin(), L.end());
  int len = L.size();
  long long p1, pr, v1, vr, k;
  while(cin >> p1 >> pr >> v1 >> vr >> k)
  {
    long long tot = 0;
    for(int i = 0; i < len - k + 1; i++)
    {
      long long awal = L[i];
      long long akhir = L[i+k-1];
      long long temp = 0;
      if(p1 <= awal && akhir <= vr)
      {
        if(i) temp = min(awal, pr) - max(p1, L[i-1] + 1LL) + 1LL;
        else temp = min(awal, pr) - p1 + 1LL;
        if(i + k < len && temp > 0) temp *= (min(vr, L[i+k] - 1LL) - max(v1, L[i+k-1]) + 1LL);
        else temp *= (vr - max(v1, L[i+k-1]) + 1LL);
      }
      swap(p1, v1); swap(pr, vr);
      if(temp > 0) tot += temp;
      temp = 0;
      if(p1 <= awal && akhir <= vr && !(p1 == v1 && pr == vr && p1 == pr))
      {
        if(i) temp = min(awal, pr) - max(p1, L[i-1] + 1LL) + 1LL;
        else temp = min(awal, pr) - p1 + 1LL;
        if(i + k < len && temp > 0) temp *= (min(vr, L[i+k] - 1LL) - max(v1, L[i+k-1]) + 1LL);
        else temp *= (vr - max(v1, L[i+k-1]) + 1LL);
        if(temp > 0 && k == 1) temp--;
      }
      if(temp > 0) tot += temp;
      swap(p1, v1); swap(pr, vr);
    }
    double ans = (double)tot/(double)(vr - v1 + 1LL)/(double)(pr - p1 + 1LL);
    printf("%.9lf\n",ans);
  }
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

void solve()
{
	ll pl,pr,vl,vr,k;
	cin>>pl>>pr>>vl>>vr>>k;
	// generate all the lucky numbers
	vector<ll> lucky;
	ll p[10];
	p[0]=1;
	for(ll i=1;i<=9;i++)
	{
		p[i]=p[i-1]*10;
	}
	for(ll d=0;d<10;d++)
	{
		for(ll i=0;i<(1LL<<d);i++)
		{
			ll s=0;
			for(ll j=0;j<d;j++)
			{
				if(i&(1LL<<j))
				{
					s+=(p[j]*4);
				}
				else
				{
					s+=(p[j]*7);
				}
			}
			lucky.push_back(s);
		}
	}
	lucky.push_back(2e9);
	sort(lucky.begin(),lucky.end());
	ll n=lucky.size();
	ll num=0;
	ll den=(pr-pl+1)*(vr-vl+1);
	for(ll i=0;i+k+1<n;i++)
	{
		ll j=i+k;
		ll range1=min(lucky[i+1],pr)-max(lucky[i]+1,pl)+1;
		ll range2=min(lucky[j+1]-1,vr)-max(lucky[j],vl)+1;
		if(range1>=0&&range2>=0)
		{
			num+=(range1*range2);
		}
	}
	// for [vl,vr] < [pl,pr]
	for(ll i=k;i<n;i++)
	{
		ll j=i-k;
		ll range1=min(lucky[i+1]-1,pr)-max(lucky[i],pl)+1;
		ll range2=min(lucky[j+1],vr)-max(lucky[j]+1,vl)+1;
		if(range1>=0&&range2>=0)
		{
			num+=(range1*range2);
		}
	}
	if(k==1)
	{
		for(auto &it:lucky)
		{
			if(it>=pl&&it<=pr&&it>=vl&&it<=vr) num--;
		}
	}
	long double ans=((1.0*num)/den);
	cout<<ans<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<fixed<<setprecision(14);
	solve();
	return 0;
}

/*
ID   : mnlm1991
PROG : D
LANG : C++
*/

#include<map>
#include<set>
#include<list>
#include<stack>
#include<queue>
#include<cmath>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;

#define PB push_back
#define MP make_pair

#define REP(i, n) for(i=0;i<(n);i++)
#define FOR(i, l, h) for(i=(l);i<=(h);i++)
#define FORD(i, h, l) for(i=(h);i>=(l);i--)
#define MM(x, v) memset(x, v, sizeof(x))

typedef vector <int> VI;
typedef vector <double> VD;
typedef vector <string> VS;
typedef pair <int, int> PII;
typedef long long LL;

const int oo = 1000000000;
__int64 lucky[10001];
int l = 0;
void DFS(__int64 x)
{
        lucky[l++] = x * 10 + 4;
        if (lucky[l - 1] <= oo)
        {
                DFS(lucky[l - 1]);
        }
        else
        {
                l--;
        }
        lucky[l++] = x * 10 + 7;
        if (lucky[l - 1] <= oo)
        {
                DFS(lucky[l - 1]);
        }
        else
        {
                l--;
        }
}
int main()
{
        int i;
        lucky[0] = -1;
        l = 1;
        DFS(0);
        sort(lucky, lucky + l);
        lucky[l] = oo;
        __int64 pl, pr;
        __int64 vl, vr;
        int k;
        while (scanf("%I64d%I64d%I64d%I64d%d", &pl, &pr, &vl, &vr, &k) != EOF)
        {
                int i;
                int j;
                double sum = 0.0;
                FOR(i, 1, l - k)
                {
                        __int64 ii = lucky[i];
                        j = i + k - 1;
                        __int64 jj = lucky[j];
                        //printf("%d %d\n", ii, jj);
                        //system("pause");
                        if (ii >= pl && lucky[i - 1] + 1 <= pr &&
                        jj <= vr && lucky[j + 1] - 1 >= vl)
                        {
                                sum += 1.0 *(min(pr, ii) - max(pl, lucky[i - 1] + 1) + 1)*(min(vr, lucky[j + 1] - 1) - max(jj, vl) + 1);
                        }
                        if (ii >= vl && lucky[i - 1] + 1 <= vr &&
                        jj <= pr && lucky[j + 1] - 1 >= pl)
                        {
                                sum += 1.0*(min(vr, ii) - max(vl, lucky[i - 1] + 1) + 1)*(min(pr, lucky[j + 1] - 1) - max(jj, pl) + 1) - (k == 1);
                        }
                }
                //printf("%lf\n", sum);
                printf("%.20lf\n", sum / (pr - pl + 1.0) / (vr - vl + 1.0));
        }
        return 0;
}

#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    vector<int> lucky(1,0);
    for ( int i = 1; i <= 9; i++ ) {
        for ( int j = 0; j < (1<<i); j++ ) {
            int b = 1, l = 0;
            for ( int k = 0; k < i; k++ ) {
                if ( j&(1<<k) ) {
                    l += 4*b;
                } else {
                    l += 7*b;
                }
                b*=10;
            }
            lucky.push_back(l);
        }
    }
    lucky.push_back(1000000001);
    sort( lucky.begin(), lucky.end() );

    int pl, pr, vl, vr, k;
    cin >> pl >> pr >> vl >> vr >> k;

    double d = 0.0;
    for ( size_t i0 = 1; i0 + k < lucky.size(); i0++ ) {
        int prange = min(pr,lucky[i0]) - max(pl,lucky[i0-1]+1) + 1;
        int vrange = min(vr,lucky[i0+k]-1) - max(vl,lucky[i0+k-1]) + 1;
        if ( prange > 0 && vrange > 0 ) {
            d += 1.0 * prange * vrange;
        }
    }

    for ( size_t i0 = 1; i0 + k < lucky.size(); i0++ ) {
        int vrange = min(vr,lucky[i0]) - max(vl,lucky[i0-1]+1) + 1;
        int prange = min(pr,lucky[i0+k]-1) - max(pl,lucky[i0+k-1]) + 1;
        if ( prange > 0 && vrange > 0 ) {
            d += 1.0 * prange * vrange;
        }
    }

    if ( k == 1 ) {
        for ( size_t i = 1; i < lucky.size()-1; i++ ) {
            if ( pl <= lucky[i] && lucky[i] <= pr && vl <= lucky[i] && lucky[i] <= vr ) {
                d -= 1.0;
            }
        }
    }

    printf( "%.12f\n", d/(pr-pl+1)/(vr-vl+1) );
    return 0;
}

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

vector<ll> num;
int n;
ll pl, pr, vl, vr, k;
ll ans = 0;

void dfs(ll x) {
	if(x >= 1e9) return;
	num.push_back(x);
	dfs(x*10+4);
	dfs(x*10+7);
}

inline ll calc(ll l, ll r, ll x, ll y) {
	if(r < x || l > y) return 0;
	if(l>r || x>y) return 0;
	if(l >= x && l <= y) return min(r, y)-l+1;
	if(r >= x && r <= y) return r-max(l, x)+1;
	if(l < x && r > y) return y-x+1;
}

int main() {
	dfs(0);
	n = num.size();
	num.push_back(1e16);
	sort(num.begin(), num.end());
	cin >> pl >> pr >> vl >> vr >> k;
	for(int i = 1; i+k-1 <= n; i++) {
		if(num[i] > vr && num[i]>pr) break;
		int j = i+k-1;
		ans += calc(num[i-1]+1, num[i], pl, pr)*calc(num[j], num[j+1]-1, vl, vr);
		ans += calc(num[j], num[j+1]-1, pl, pr)*calc(num[i-1]+1, num[i], vl, vr);
		if(k == 1) {
			if(calc(pl, pr, num[i], num[i]) && calc(vl, vr, num[i], num[i]))
				ans--;
		}
	}
	printf("%.12lf", ans*1.0/(vr-vl+1)/(pr-pl+1), 1.0);

	return 0;
}

#include <cstdio>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <ctime>

#define ll long long

using namespace std;

vector <int> v;

void go(int num = 0)
{
    if (num!=0&&num<=1000000000) v.push_back(num);
    if (10LL*num>=1000000000LL) return;
    go(10*num+4);
    go(10*num+7);
}

int inter(int l1,int r1,int l2,int r2)
{
    if (min(r1,r2)-max(l1,l2)+1>=0) return min(r1,r2)-max(l1,l2)+1;
    return 0;
}

double pp(int l1,int r1,int l2,int r2,int k)
{
    double ans=0;
    for(int l=l1;l<=r1;l++)
        for(int r=l2;r<=r2;r++)
        {
            int L=min(l,r),R=max(l,r),cnt=0;
            for(int i=1;i<v.size()-1&&v[i]<=R;i++)
                if (v[i]>=L) cnt++;
            if (cnt==k) ans++;
        }
    ans/=(r1-l1+1); ans/=(r2-l2+1);
    return ans;
}

long double solve(int l1,int r1,int l2,int r2,int k)
{
    ll tot=1LL*(r1-l1+1)*(r2-l2+1);
    long double cnt=0;
    for(int i=1;i<v.size()-1;i++)
        if (i+k-1<v.size()-1)
        {
            cnt+=1LL*inter(l1,r1,v[i-1]+1,v[i])*inter(l2,r2,v[i+k-1],v[i+k]-1);
//          if (i<5) cout << inter(l1,r1,v[i-1]+1,v[i]) << "    " << inter(l2,r2,v[i+k-1],v[i+k]-1) << endl;
        }
//  cout << endl;
    for(int i=1;i<v.size()-1;i++)
        if (i+k-1<v.size()-1)
        {
            cnt+=1LL*inter(l2,r2,v[i-1]+1,v[i])*inter(l1,r1,v[i+k-1],v[i+k]-1);
//          if (i<5) cout << inter(l1,r1,v[i-1]+1,v[i]) << "    " << inter(l2,r2,v[i+k-1],v[i+k]-1) << endl;
        }
    if (k==1)
    {
        for(int i=1;i<v.size()-1;i++)
            if (l1<=v[i]&&v[i]<=r1&&l2<=v[i]&&v[i]<=r2) cnt--;
    }
    long double ans=cnt;
    ans/=(r1-l1+1); ans/=(r2-l2+1);
    return ans;
}

int main()
{
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);
    go();
    v.push_back(-1);
    v.push_back(1000000007);
    sort(v.begin(),v.end());
    int l1,r1,l2,r2,k,K=30;
    cin >> l1 >> r1 >> l2 >> r2 >> k;
/*  for(l1=1;l1<K;l1++)
        for(r1=l1;r1<K;r1++)
            for(l2=1;l2<K;l2++)
                for(r2=l2;r2<K;r2++)
                    for(k=1;k<10;k++)
                        if (fabs(solve(l1,r1,l2,r2,k)-pp(l1,r1,l2,r2,k))>1e-7)
                        {
                            cout << l1 << " " << r1 << "    " << l2 << "    " << r2 << "    " << k << endl;
                        }*/
    printf("%.9lf\n",solve(l1,r1,l2,r2,k));
    if (k==0) return -1;
//  printf("%.12lf\n",pp(l1,r1,l2,r2,k));
//  cout << cnt << endl;
    return 0;
}

#include<iostream>
#include<algorithm>
using namespace std;
__int64 pl,pr,vl,vr,k;
__int64 len=0;
__int64 c[10009];
void dfs(__int64 n)//生成4,7...的表
{
	if(n>pr&&n>vr)
		return;
	c[len]=n;
	len++;
	dfs(n*10+4);
	dfs(n*10+7);
}

double poss(__int64 l1,__int64 r1,__int64 l2,__int64 r2)//计算(l1,r1)在(l2,r2)的概率
{
	if(l1<l2)l1=l2;
	if(r1>r2)r1=r2;
	if(l1>r1)return 0;
	else return (r1-l1+1)*1.0/(r2-l2+1);
}

int main()
{

	scanf("%d%d%d%d%d",&pl,&pr,&vl,&vr,&k);

	__int64 i;
	dfs(0);
	c[len]=1000000000;
	len--;
	double ret=0;
	sort(&c[0],&c[len+1]);
	for(i=1;i+k-1<=len;i++)
	{
		ret+=poss(max(c[i-1]+1,pl),c[i],pl,pr)*poss(c[i+k-1],min(vr,c[i+k]-1),vl,vr);//zuo
		ret+=poss(max(c[i-1]+1,vl),c[i],vl,vr)*poss(c[i+k-1],min(pr,c[i+k]-1),pl,pr);//
		if(k==1)
		{
			ret-=poss(c[i],c[i],pl,pr)*poss(c[i],c[i],vl,vr);
		}
	}
	printf("%.11lf",ret);

}

#pragma comment (linker, "/STACK:200000000")
#define _CRT_SECURE_NO_DEPRECATE
#define _SECURE_SCL 0
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <stack>
#include <sstream>
#include <vector>

using namespace std;

typedef long long int64;
const int INF = (int) 1E9;
const int64 INF64 = (int64) 1E18;
const double EPS = 1E-9;
const double PI = acos((double)0) * 2;

#define forn(i,n)  for (int i=0; i<int(n); ++i)
#define ford(i,n)  for (int i=int(n)-1; i>=0; --i)
#define fore(i,l,n)  for (int i=int(l); i<int(n); ++i)
#define all(a)  a.begin(), a.end()
#define fs  first
#define sc  second
#define pb  push_back
#define mp  make_pair

vector<int> num;
int l1, r1, l2, r2, k;

bool read() {
	return !! (cin >> l1 >> r1 >> l2 >> r2 >> k);
}

int64 prob (int first1, int last1, int first2, int last2) {
	first1 = max (first1, l1);
	last1 = min (last1, r1);
	first2 = max (first2, l2);
	last2 = min (last2, r2);
	if (first1 > last1 || first2 > last2)  return 0;
	return (last1 - first1 + 1) * 1ll * (last2 - first2 + 1);
}

void solve() {
	int64 ans = 0;
	forn(i,num.size()-k+1) {
		int first = num[i],
			last = num[i+k-1],
			pfirst = i ? num[i-1]+1 : 1,
			nlast = i+k<(int)num.size() ? num[i+k]-1 : INF;
		ans += prob (pfirst, first, last, nlast);
		ans += prob (last, nlast, pfirst, first);
		if (k == 1)
			ans -= prob (first, first, first, first);
	}

	double dans = ans * 1.0 / ((r1 - l1 + 1) * 1ll * (r2 - l2 + 1));
	printf ("%.20lf\n", dans);
}

int main() {

	vector<int> prev;
	prev.pb (0);
	for(;;) {
		vector<int> cur;
		forn(i,prev.size()) {
			long long n = prev[i] * 10ll;
			if (n + 4 <= INF)
				cur.pb (int (n + 4));
			if (n + 7 <= INF)
				cur.pb (int (n + 7));
		}
		if (cur.empty())  break;
		forn(i,cur.size())
			num.pb (cur[i]);
		prev = cur;
	}

#ifdef SU2_PROJ
	freopen ("input.txt", "rt", stdin);
	freopen ("output.txt", "wt", stdout);
	while (read())
		solve();
#else
	if (!read())  throw;
	solve();
#endif
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mod 1000000007
#define vll vector<ll>
#define inf 1e12
#define pll pair<ll,ll>
#define ff first
#define ss second
#define PI acos(-1)
#define pr 998244353
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

//getline(cin, s);
//cout<<fixed<<setprecision(12)<<;
/*
ll power(ll x,ll y)
{
	ll res=1;
	while(y>0)
	{
		if(y%2==1)res=(res*x)%pr;
		y=y/2;
		x=(x*x)%pr;
	}
	return res;
}

ll inv(ll a)
{
return power(a,pr-2);
}
/*
ll fact[2000007];
ll inr[2000007];
void pre()
{
	fact[0]=1;
	for(ll i=1;i<=2000005;i++)fact[i]=(fact[i-1]*i)%mod;
	inr[0]=1;
	for(ll i=1;i<=2000005;i++)inr[i]=inv(fact[i]);
}
ll ncr(ll n,ll r)
{
	ll a=(fact[n]*inr[r])%mod;
	ll b=(a*inr[n-r])%mod;
	return b;
}

ll spf[200005];
void sieve()
{
	for(ll i=2;i*i<=200005;i++)
	{
		if(spf[i]==0)
		{
			for(ll j=i+i;j<=200005;j+=i)
			{
				if(spf[j]==0)
				{
					spf[j]=i;
				}
			}
		}
	}
}
*/
ll l1, r1, l2, r2, k;
vll v;

void gen(ll x)
{
	if(x <= 1e9)
		v.push_back(x);
		//cout<<x<<" ";
	if(x > 1e9)
		return;
	gen(x * 10 + 4);
	gen(x * 10 + 7);
}

int main()
{
	fastio;
	cin >> l1 >> r1 >> l2 >> r2 >> k;
	gen(0);
	v.push_back(2e9);
	sort(v.begin(), v.end());
	ll n = v.size();
	ld num = 0;
	ld den = (r2 - l2 + 1) * (r1 - l1 + 1);
	for(ll i = 0; i + k + 1 < n; i++)
	{
		ll j = i + k;
		ll range1 = min(v[i + 1], r1) - max(v[i] + 1, l1) + 1;
		ll range2 = min(v[j + 1] - 1, r2) - max(v[j], l2) + 1;
		if(range1 >= 0 && range2 >= 0)
			num += range1 * range2;
	}
	for(ll i = k; i < n; i++)
	{
		ll j = i - k;
		ll range1 = min(v[i + 1] - 1, r1) - max(v[i], l1) + 1;
		ll range2 = min(v[j + 1], r2) - max(v[j] + 1, l2) + 1;
		if(range1 >= 0 && range2 >= 0)
			num += range1 * range2;
	}
	if(k == 1)
	{
		for(ll i=0;i<v.size();i++)
		{
			ll it=v[i];
			if(it >= l1 && it <= r1 && it >= l2 && it <= r2)
				num--;
		}
	}
	double ans = num / den;
	cout << fixed << setprecision(12) << ans;
	return 0;
}

#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

typedef long long LL;
typedef long double LD;

const int MAXN = 1e9;
const LL INF = 1LL<<62;

LL pl, pr, vl, vr, k;

LD f(LL l, LL r, LL L, LL R) {
	if(r < L || R < l) return 0;
	LL left = max(l, L);
	LL right = min(r, R);

	return LD(right-left+1)/(R-L+1);

}
int main() {
	scanf("%I64d %I64d %I64d %I64d %I64d", &pl, &pr, &vl, &vr, &k);
	vector<LL> numbers;

	queue<LL> current;
	current.push(4);
	current.push(7);

	while(!current.empty()) {
		LL top = current.front();
		current.pop();
		if(top > 100*LL(MAXN)) continue;
		numbers.push_back(top);
		current.push(10*top + 4);
		current.push(10*top + 7);
	}

	sort(numbers.begin(), numbers.end());

	LD res = 0;

	for(int i = 0; i < numbers.size(); i++) {
		int j = i+k-1;
		if(j >= numbers.size()) continue;

		LL Aleft = (i > 0) ? numbers[i-1]+1 : 0;
		LL Aright =  numbers[i];

		LL Bleft = numbers[j];
		LL Bright = (j+1 < numbers.size()) ? numbers[j+1]-1 : INF;

		if(Aleft > MAXN || Bleft > MAXN) break;

		res += f(Aleft, Aright, pl, pr)*f(Bleft, Bright, vl, vr);
		res += f(Aleft, Aright, vl, vr)*f(Bleft, Bright, pl, pr);

		if(Aright == Bleft) res -= f(Aright, Aright, pl, pr)*f(Aright, Aright, vl, vr);

	}

	printf("%.11llf\n", res);

}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <utility>
#include <sstream>
#include <algorithm>
using namespace std;
#define ll long long
const long long LINF = ~(((long long)0x1)<<63)/2;
const int INF=0X3F3F3F3F;
const double eps=1e-7;
vector<ll> p;
void dfs(ll now)
{
    if(now>400000000000LL)
        return;
    if(now!=0)
       p.push_back(now);
    dfs(now*10+4);
    dfs(now*10+7);
}
int main()
{
    dfs(0);
    sort(p.begin(),p.end());
    //cout<<p[0]<<" "<<p.size()<<endl;
    //for(int i=0;i<p.size();i++)
        //cout<<p[i]<<endl;
    ll pl,pr,vl,vr,l1,r1,i,j,k,l2,r2;
    cin>>pl>>pr>>vl>>vr>>k;
    ll ans=0;
    for(i=0;i<p.size();i++)
    {
        l1=i==0?1:p[i-1]+1;
        r1=p[i];
        l1=max(l1,pl);
        r1=min(r1,pr);
        if(l1>r1)
            continue;
        if(i+k<p.size())
        {
            l2=p[i+k-1];
            r2=p[i+k]-1;
            l2=max(l2,vl);
            r2=min(r2,vr);
            if(l2>r2)
                continue;
            ans+=(r2-l2+1)*(r1-l1+1);
        }
    }
    for(i=0;i<p.size();i++)
    {
        l2=i==0?1:p[i-1]+1;
        r2=p[i];
        l2=max(l2,vl);
        r2=min(r2,vr);
        if(l2>r2)
            continue;
        if(i+k<p.size())
        {
            l1=p[i+k-1];
            r1=p[i+k]-1;
            l1=max(l1,pl);
            r1=min(r1,pr);
            if(l1>r1)
                continue;
            ans+=(r2-l2+1)*(r1-l1+1);
            if(l1==r2)
                ans--;
        }
    }
    double re=ans*1.0/((pr-pl+1)*(vr-vl+1));
     printf("%.12lf\n",re);
    return 0;
}

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

vector<int> luc;

int init(int dg){
    for(int i=0;i<(1<<dg);++i){
        int add=0,base=1;
        for(int j=0;j<dg;++j){
            add+=base*((i&(1<<j))?7:4);
            base*=10;
        }
        luc.push_back(add);
    }
}
void init(){
    luc.push_back(-7122);
    for(int i=1;i<=9;++i)init(i);
    luc.push_back(1000007122);
    // for(int i:luc)cout<<i<<" "; cout<<endl;
    // cout<<"luc size: "<<luc.size()<<endl;
}

int main(){
    init();
    int pl,pr,vl,vr,k; cin>>pl>>pr>>vl>>vr>>k;
    int lptr=1,rptr=k;
    long double ans=0;
    while(rptr<luc.size()-1){
        int pll=max(luc[lptr-1]+1,pl);
        int prr=min(luc[lptr],pr);
        int vll=max(luc[rptr],vl);
        int vrr=min(luc[rptr+1]-1,vr);
        if(pll<=prr && vll<=vrr){
            ans+=((long double)(prr-pll+1)/(pr-pl+1))*((long double)(vrr-vll+1)/(vr-vl+1));
        }
        ++lptr, ++rptr;
    }
    swap(pl,vl); swap(pr,vr);
    lptr=1,rptr=k;
    while(rptr<luc.size()-1){
        int pll=max(luc[lptr-1]+1,pl);
        int prr=min(luc[lptr],pr);
        int vll=max(luc[rptr],vl);
        int vrr=min(luc[rptr+1]-1,vr);
        if(pll<=prr && vll<=vrr){
            ans+=((long double)(prr-pll+1)/(pr-pl+1))*((long double)(vrr-vll+1)/(vr-vl+1));
        }
        ++lptr, ++rptr;
    }
    // if(vl==pl && pl==vr &&  vr==pr)ans/=2;
    if(k==1)for(int i=1;i<luc.size()-1;++i){
        if(pl<=luc[i] && luc[i]<=pr && vl<=luc[i] && luc[i]<=vr){
            ans-=((long double)1/(pr-pl+1))*((long double)1/(vr-vl+1));
        }
    }
    cout<<fixed<<setprecision(20)<<ans<<endl;
}

#include <stdio.h>
#include <algorithm>

using namespace std;

int A[1 << 11], size = 0;

void init() {
  A[size++] = 0;
  for (int n = 1; n <= 9; ++n) {
    for (int i = 0; i < (1 << n); ++i) {
      int t = 0;
      for (int j = 0; j < n; ++j) {
        t *= 10;
        if ((i >> (n - j - 1)) & 1) t += 7;
        else t += 4;
      }
      A[size++] = t;
    }
  }
  A[size++] = 1000000001;
}

int main() {
  init();
  int pl, pr, vl, vr, k;
  scanf("%d%d", &pl, &pr);
  scanf("%d%d", &vl, &vr);
  scanf("%d", &k);
  double tot = (double) (pr - pl + 1) * (vr - vl + 1);
  double cnt = 0;
  for (int i = 1; i + k < size; ++i) {
    if (pl <= A[i] && A[i + k - 1] <= vr) {
      int al = max(A[i - 1] + 1, pl), ar = min(A[i], pr);
      int bl = max(A[i + k - 1], vl), br = min(A[i + k] - 1, vr);
      if (al <= ar && bl <= br) {
        cnt += (double) (ar - al + 1) * (br - bl + 1);
      }
    }
    if (vl <= A[i] && A[i + k - 1] <= pr) {
      int al = max(A[i - 1] + 1, vl), ar = min(A[i], vr);
      int bl = max(A[i + k - 1], pl), br = min(A[i + k] - 1, pr);
      if (al <= ar && bl <= br) {
        cnt += (double) (ar - al + 1) * (br - bl + 1);
      }
    }
    if (k == 1 && pl <= A[i] && A[i] <= pr && vl <= A[i] && A[i] <= vr) cnt -= 1.0;
  }
  printf("%.9lf\n", cnt / tot);
  return 0;
}

#include<cstdio>
#include<algorithm>
#include<vector>
#include<memory.h>
#include<map>
#include<set>
#include<iostream>
#include<string.h>
#include<string>
using namespace std;
vector< int > h, temp[2];
int inter(int a, int b, int c, int d)
{
    return max(0, min(b, d) - max(a, c));
}
long long count(int x, int y, int a, int b, int c, int d)
{
    long long h1, h2;
    h1 = inter(h[x] + 1, h[x + 1] + 1, a, b);
    h2 = inter(h[y], h[y + 1], c, d);
    return h1 * h2;
}
void gen_h()
{
    int i;
    temp[1].push_back(4);
    temp[1].push_back(7);
    h.push_back(4);
    h.push_back(7);
    for(i = 2; i < 10; ++i)
    {
        temp[i%2].clear();
        int k = (i + 1) % 2;
        for(int j = 0; j < temp[k].size(); ++j)
        {
            int m = temp[k][j] * 10;
            temp[i%2].push_back(m + 4);
            temp[i%2].push_back(m + 7);
            h.push_back(m + 4);
            h.push_back(m + 7);
        }
    }
    h.push_back(0);
    h.push_back((int)(1e9 + 1.05));
    sort(h.begin(), h.end());
}
int main()
{
#ifdef _DEBUG
    freopen("in.txt", "rt", stdin);
#endif
    int n, i;
    int p1, p2, v1, v2, k;
    gen_h();
    scanf("%d%d", &p1, &p2);
    ++p2;
    scanf("%d%d", &v1, &v2);
    ++v2;
    scanf("%d", &k);
    int x = 0, y = k;
    long long  ans = 0;
    while(y + 1 < h.size())
    {
        ans += count(x, y, p1, p2, v1, v2);
        ans += count(x, y, v1, v2, p1, p2);
        if( x != 0 && x == y - 1 && p1 <= h[x] && h[x] < p2 && v1 <= h[x] && h[x] < v2)
            --ans;
        ++x; ++y;
    }
    printf("%.11lf", (double)ans/(p2 - p1)/(v2 - v1));
    return 0;
}

#include<bits/stdc++.h>
#define int long long int
#define ll long long int
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD1 1e9+7
#define MOD 998244353
#define f first
#define s second
//#define endl '\n'
#define pii pair<int,int>
#define precise(i) cout<<fixed<<setprecision(i)
using namespace std;
const double PI = atan(1.0)*4;
const int64_t INF=100000000000000003;
const int32_t LOG=21;
vector<int> vals[12];
vector<int> v;
void lucky()
{
	 int cur=0;
	 int i=1;
	 vals[0].push_back(0);
	 while(i<10)
	 {
        rep(j,0,vals[i-1].size())
        {
        	int no1=vals[i-1][j]*10+4,no2=vals[i-1][j]*10+7;
        	v.push_back(no1);v.push_back(no2);
        	vals[i].push_back(no1);vals[i].push_back(no2);
        }
        i++;
	 }
	 v.push_back(0);
	 v.push_back(1e9+7);
	 sort(v.begin(),v.end());
}
int intersect(int l1,int r1,int l2,int r2)
{
	if(l1>l2){swap(l1,l2);swap(r1,r2);}
	if(l1<=l2 && r2<=r1)return r2-l2+1;
	return max(r1-l2+1,0LL);

}
double solve(int l1,int r1,int dist1,int l2,int r2,int dist2,int k)
{
   if(l1>r1 || l2>r2)return 0;
   int n=v.size()-1;
   double ans=0.0000;
   rep(i,1,n)
   {
   	  int j=i+k-1;
   	  if(j>=n)break;
   	  int range1_l=v[i-1]+1;
   	  int range1_r=v[i];
      int range2_l=v[j];
      int range2_r=v[j+1]-1;
      double val1=intersect(range1_l,range1_r,l1,r1);
      double val2=intersect(range2_l,range2_r,l2,r2);
      val1=val1/dist1;
      val2=val2/dist2;
      double toAdd=val1*val2;
      ans+=toAdd;
   }
   return ans;
}
double count1(int l,int r)
{
	int ans=0;
	rep(i,1,v.size()-1)
	{
         if(v[i]>=l && v[i]<=r)ans++;
	}
	return ans;
}
int32_t main()
{
	getFaster;
	lucky();
	int l1,r1,l2,r2,k;
	cin>>l1>>r1>>l2>>r2>>k;
    if(l1>l2 || (l1==l2 && r1>r2))
    {swap(l1,l2);swap(r1,r2);}
    int dist1=r1-l1+1,dist2=r2-l2+1;
    double ans=0.000000;
    if(l2<=r1 && r1<r2)
    {
    	 ans+=solve(l1,l2-1,dist1,r1+1,r2,dist2,k);
    	 ans+=solve(l1,l2-1,dist1,l2,r1,dist2,k);
    	 ans+=solve(l2,r1,dist1,r1+1,r2,dist2,k);
    	 ans+=2.0000*solve(l2,r1,dist1,l2,r1,dist2,k);
    	 if(k==1)
    	 ans-=count1(l2,r1)/(dist2*dist1);
    }
    else if(l2<=r1 && r2<=r1)
    {
    	ans+=solve(l1,l2-1,dist1,l2,r2,dist2,k);
    	ans+=solve(l2,r2,dist2,r2+1,r1,dist1,k);
    	ans+=2*solve(l2,r2,dist1,l2,r2,dist2,k);
    	if(k==1)
    	ans-=count1(l2,r2)/(dist2*dist1);
    }
    else
    {
    	 ans+=solve(l1,r1,dist1,l2,r2,dist2,k);
    }
    precise(10)<<ans<<endl;
    return 0;
}

#include <map>
#include <set>
#include <list>
#include <stack>
#include <cmath>
#include <queue>
#include <ctime>
#include <cfloat>
#include <vector>
#include <string>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <utility>
#include <iostream>
#include <algorithm>

#define INF 0x3F3F3F3F
#define LINF 0x3F3F3F3FFFFFFFFFLL

#define FILL(X, V) memset( X, V, sizeof(X) )
#define TI(X) __typeof((X).begin())
#define ALL(V) V.begin(), V.end()
#define SIZE(V) int((V).size())

#define FOR(i, a, b) for(int i = a; i <= b; ++i)
#define RFOR(i, b, a) for(int i = b; i >= a; --i)
#define REP(i, N) for(int i = 0; i < N; ++i)
#define RREP(i, N) for(int i = N-1; i >= 0; --i)
#define FORIT(i, a) for( TI(a) i = a.begin(); i != a.end(); i++ )

#define PB push_back
#define MP make_pair

template<typename T> T inline SQR( const T &a ){ return a*a; }
template<typename T> T inline ABS( const T &a ){ return a < 0 ? -a : a; }
template<typename T> T inline MIN( const T& a, const T& b){ if( a < b ) return a; return b; }
template<typename T> T inline MAX( const T& a, const T& b){ if( a > b ) return a; return b; }

const double EPS = 1e-9;
inline int SGN( double a ){ return a > EPS ? 1 : (a < -EPS ? -1 : 0); }
inline int CMP( double a, double b ){ return SGN(a - b); }

typedef long long int64;
typedef unsigned long long uint64;

using namespace std;

vector< int64 > lucky;

void build( int64 now ){
	if( now > 1000000000LL ) return;
	lucky.PB( 10LL*now + 4LL );
		build( 10LL*now + 4LL );
	lucky.PB( 10LL*now + 7LL );
		build( 10LL*now + 7LL );
}

double prob( double a, double b, double c, double d ){
	return (min(d,b)-max(c,a)+1)/(d-c+1);
}

int main( int argc, char* argv[] ){

	ios::sync_with_stdio( false );

	build( 0 ); sort( ALL(lucky) );

	int64 pl, pr, vl, vr, k;
	cin >> pl >> pr >> vl >> vr >> k;

	double ans = 0.0;
	for( int i = 0; i+k-1 < SIZE(lucky); i++ ){

		int64 lo = lucky[i];
		int64 hi = lucky[i+k-1];

		int64 alo, ahi;

		if( i ) alo = lucky[i-1]+1;
		else alo = 1;

		if( i+k < SIZE(lucky) ) ahi = lucky[i+k]-1;
		else ahi = 1000000000;

		double p1, p2;
		p1 = 0.0;
		p2 = 0.0;

		//cout << alo << " " << lo << endl;
		//cout << hi << " " << ahi << endl;

		if( (pl <= alo && alo <= pr) || (alo <= pl && pl <= lo) )
			p1 = prob( alo, lo, pl, pr );

		if( (vl <= hi && hi <= vr) || (hi <= vl && vl <= ahi) )
			p2 = prob( hi, ahi, vl, vr );

		//cout << p1 << " - " << p2 << endl;
		ans += p1*p2;

		p1 = 0.0;
		p2 = 0.0;

		if( (vl <= alo && alo <= vr) || (alo <= vl && vl <= lo) )
			p1 = prob( alo, lo, vl, vr );

		if( (pl <= hi && hi <= pr) || (hi <= pl && pl <= ahi) )
			p2 = prob( hi, ahi, pl, pr );
		//cout << p1 << " - " << p2 << endl;
		ans += p1*p2;
		if( k == 1 && pl <= lucky[i] && lucky[i] <= pr && vl <= lucky[i] && lucky[i] <= vr )
			ans -= prob(lucky[i],lucky[i],pl,pr)*prob(lucky[i],lucky[i],vl,vr);

	}

	cout << fixed << setprecision(20) << ans << "\n";

	return 0;
}

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

#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define ll long long
#define mkp make_pair

const int N = 2e6 + 9;
const int INF = 1e9 + 9;
const int mod = 1e9;
const int sz = (1 << 19) - 1;

#define int ll

int v[N], cnt;

int calc(int l, int r, int l2, int r2) {
	int a = max(l, l2);
	int b = min(r, r2);
	return max(b - a + 1, 0LL);
}

void solve() {
	int vl, vr, pl, pr;
	int k;
	cin >> pl >> pr >> vl >> vr >> k;
	double ans = 0;
	v[++cnt] = 0;
	for (int len = 1; len <= 9; ++ len) {
		for (int mask = 0; mask < (1 << len); ++ mask) {
			int sum = 0;
			for (int j = 0; j < len; ++ j) {
				int x = 4;
				if (mask & (1 << j))
					x = 7;
				sum *= 10;
				sum += x;
			}
			v[++cnt] = sum;
		}
	}
	sort(v + 1, v + 1 + cnt);
	v[++cnt] = INF;
	for (int i = 1; i < cnt; ++ i) {
		ans += calc(v[i] + 1 , v[i + 1] , pl , pr) * calc(v[i + k] , v[i + k + 1] - 1 , vl , vr);
        ans += calc(v[i] + 1 , v[i + 1] , vl , vr) * calc(v[i + k] , v[i + k + 1] - 1, pl , pr);
        if(k == 1) {
            ans -= calc(v[i + 1] , v[i + 1] , vl , vr) * calc(v[i + 1] , v[i + 1] , pl , pr);
        }
	}
	double res = (pr - pl + 1) * (vr - vl + 1);
	cout << fixed << setprecision(12) << ans / res;
}

main() {
	cerr << "Ready\n";
	solve();
	return 0;
}
		 	  						  			  	 	 		 	 	 	//hellobig_tq

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair

#define N 100005
#define M 200005
#define seed 23333
#define Mo 998244353

using namespace std;
int i,j,m,n,p,k,pl,pr,vl,vr;
long long a[N],ans;
void Work(long long x)
{
	 if (x>1e10) return;
	 a[++a[0]]=x;
	 Work(x*10+4); Work(x*10+7);
}
long long work(long long sl,long long sr,long long el,long long er)
{
	  return max(0ll,min(sr,er)-max(sl,el)+1);
}
int main()
{
	Work(4); Work(7);
	sort(a+1,a+a[0]+1);
	scanf("%d%d%d%d%d",&pl,&pr,&vl,&vr,&k);
	for (i=1;i<=a[0];++i) if (k==1&&pl<=a[i]&&a[i]<=pr&&vl<=a[i]&&a[i]<=vr) --ans;
	int A=a[0]; a[0]=0;
	for (i=1;i+k<=A;++i)  ans+=1ll*work(pl,pr,a[i-1]+1,a[i])*work(vl,vr,a[i+k-1],a[i+k]-1),
	ans+=1ll*work(pl,pr,a[i+k-1],a[i+k]-1)*work(vl,vr,a[i-1]+1,a[i]);
	printf("%.10lf\n",1.*ans/(1.*(pr-pl+1)*(vr-vl+1)));
}

#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
const int INF = 1e9 + 10;

bool ch(int a)
{
    while (a > 0)
    {
        if (a % 10 != 4 && a % 10 != 7)
            return false;
        a /= 10;
    }
    return true;
}
int a[2000], kol = 0;

long long schetl(int l, int r, int d)
{
    if (l > a[d])
        return 0;
    if (r < a[d - 1])
        return 0;
    int k;
    k = min(a[d], r) - max(a[d - 1] + 1, l);
    if (k >= 0)
        return k + 1;
    else
        return 0;
}

long long schetr(int l, int r, int d)
{
    if (r < a[d])
        return 0;
    if (l > a[d + 1])
        return 0;
    int k;
    k = min(a[d + 1] - 1, r) - max(a[d], l);
    if (k >= 0)
        return k + 1;
    else
        return 0;
}

int main()
{
   // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int i, uk = 1, k;
    long long res = 0, x, y, sum, d, zz;
    long long pl, pr, vl, vr;
    cin >> pl >> pr >> vl >> vr >> k;
    for (i = 0; i < 1024; i++)
    {
        x = i;
        d = 0;
        while(x > 1)
        {
            d *= 10;
            if (x % 2 == 0)
                d += 4;
            else
                d += 7;
            x /= 2;
        }
        a[kol] = d;
        kol++;
    }
    a[kol] = INF;
    kol++;
    sort(a, a + kol);
    while (uk + k < kol)
    {
        x = schetl(pl, pr, uk);
        y = schetr(vl, vr, uk + k - 1);
        res += x * y;
        x = schetl(vl, vr, uk);
        y = schetr(pl, pr, uk + k - 1);
        res += x * y;
        uk++;
    }
      for (i = 0; i < kol - 1; i++)
        if (a[i] >= pl && a[i] <= pr && a[i] >= vl && a[i] <= vr && k == 1)
            res--;
    sum = (1 + pr - pl) * (vr - vl + 1);
    cout.precision(15);
    long double z, res1;
    res1 = res;
    z = res1 / sum;
    cout << fixed << z;

    return 0;
}

#include <iostream>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <string>
#include <cmath>
#include <bitset>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <ctime>
#include <cstring>
#include <list>
//#include <forward_list>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstdio>

const double EPS = 0.00000001;
const long long mod = 1000000000 + 7;
using namespace std;
#define ll long long
#define ull unsigned long long
#define mk make_pair

//----------------------------

//#define cin fin
//
//#define cout fout

//----------------------------

#ifdef cin
ifstream fin("/Users/green/ios/C++/C++/in.in");
#endif
#ifdef cout
ofstream fout("out.out");
#endif

int isValid(ll x) {
    while(x) {
        if(x % 10 != 4 || x % 10 != 7) return 0;
        x /= 10;
    }
    return 1;
}

ll pl, pr, vl, vr;
int n, k;

vector<ll> a;

int lower(int i, int l, int r) {
    int l1 = 0;

    if(a[i] < l) l1 = 0;
    else if(a[i] <= r) {
        if(l > a[i - 1]) l1 = a[i] - l + 1;
        else l1 = a[i] - a[i - 1];
    } else if(a[i] > r && r > a[i - 1]) {
        if(l > a[i - 1]) l1 = r - l + 1;
        else l1 = r - a[i - 1];
    } else l1 = 0;

    return l1;
}

int upper(int i ,int l, int r) {
    int ans = 0;

    if(a[i + 1] <= l) ans = 0;
    else if(a[i + 1] <= r) {
        if(l > a[i]) ans = a[i + 1] - l;
        else ans = a[i + 1] - a[i];
    } else if(r < a[i + 1] && r >= a[i]) {
        if(l >= a[i]) ans = r - l + 1;
        else ans = r - a[i] + 1;
    } else ans = 0;

    return ans;
}

int main() {
    ios::sync_with_stdio(0);

    cin >> pl >> pr >> vl >> vr >> k;

    queue<ll> q;
    q.push(4);
    q.push(7);
    while(!q.empty()) {
        ll u = q.front();
        q.pop();
        if(u >= min(pl, vl) && u <= max(pr, vr)) a.push_back(u);
        if(u < max(pr, vr)) {
            q.push(u * 10 + 4);
            q.push(u * 10 + 7);
        }
    }
    a.push_back(min(pl, vl) - 1);
    a.push_back(max(pr, vr) + 1);
    sort(a.begin(), a.end());

    n = a.size();
    double ans = 0;
    for(int i = 1, j = k; j < n - 1; j++, i++) {

        ll l1 = lower(i, pl, pr);
        ll l2 = lower(i, vl, vr);
        ll r1 = upper(j, pl, pr);
        ll r2 = upper(j, vl, vr);

        double p1 = 1.0 * l1 / (pr - pl + 1) * 1.0 * r2 / (vr - vl + 1);
        double p2 = 1.0 * l2 / (vr - vl + 1) * 1.0 * r1 / (pr - pl + 1);

        ans += p1 + p2;
        if(k == 1 && a[i] <= pr && a[i] >= pl && a[i] <= vr && a[i] >= vl) {
            ans -= 1.0 / (pr - pl + 1) * 1.0 / (vr - vl + 1);
        }
    }

    cout.precision(18);
    cout << fixed << ans << endl;

    return 0;
}

#include <iostream>
#include <algorithm>
#include <fstream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <iomanip>

using namespace std;

#define rep(i,o,n) for (int i=o;i<=n;i++)
#define rd cin >>
#define w cout <<
#define wl cout << endl
#define road pair<int,int>
//#define cin inf
//#define cout of
#define ll long long

int moshtarak(ll n,ll m,ll n1,ll m1)
{
	if (n1>m || m1<n) return 0;
	if (n>=n1 && n<=m1 && m>=n1 && m<=m1) return m-n+1;
	if (n1>=n && n1<=m && m1>=n && m1<=m) return m1-n1+1;
	if (n1>=n && n1<=m) return m-n1+1;
	if (m1>=n && m1<=m) return m1-n+1;
}

ll n2,m2,n,m,n1,m1,a[10000],as=0,k,b[10];

void rec(ll h)
{
	if (h==10)
	{
		ll j=0,h=1,t=0;
		rep(i,1,8)
			if (b[i]==0 && b[i+1]!=0) t = 1;
		rep(i,1,9)
		{
			j += b[i] * h;
			h *= 10;
		}
		if (j!=0 && j>=n2 && j<=m2 && t==0) { as++; a[as] = j; }
	}
	else
		rep(i,0,2)
		{
			if (i==0) { b[h] = 4; rec(h+1); }
			if (i==1) { b[h] = 7; rec(h+1); }
			if (i==2) { b[h] = 0; rec(h+1); }
		}

}

int main()
{
	ifstream inf("input.txt");
	ll ans = 0;
	rd n >> m >> n1 >> m1 >> k;
	n2 = min(n,n1); m2 = max(m,m1);
	rec(1);
	sort(a+1,a+as+1);
	a[0] = n2-1; a[as+1] = m2+1;
	/*rep(i,0,as+1)
		w a[i] << ' ';*/
	rep(i,1,as-k+1)
	{
		ll h = moshtarak(a[i-1]+1,a[i],n,m); //if (i!=1 && h!=0) h--;
		ll h1 = moshtarak(a[i+k-1],a[i+k]-1,n1,m1); //if (i!=as-k+1 && h1!=0) h1--;
		ans += h*h1;
		//w h << ' ' << h1 << endl;
	}
	rep(i,1,as-k+1)
	{
		ll h = moshtarak(a[i-1]+1,a[i],n1,m1); //if (i!=1 && h!=0) h--;
		ll h1 = moshtarak(a[i+k-1],a[i+k]-1,n,m); //if (i!=as-k+1 && h1!=0) h1--;
		ans += h*h1;
		//w h << ' ' << h1 << endl;
	}
	if (k==1)
		rep(i,1,as)
			if (moshtarak(a[i],a[i],n,m)==1 && moshtarak(a[i],a[i],n1,m1)==1) ans--;
	double h = ((m-n+1)*(m1-n1+1));
	double j = ans;
	//w j << ' ' << h << ' ';
	w setprecision(11) << j/h;
}

#include<iostream>
#include<sstream>
#include<string>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<set>
#include<bitset>
#include<algorithm>
#include<list>
#include<utility>
#include<functional>
#include <deque>
#include <numeric>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <ctime>

#include<cmath>
#include<math.h>

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>

using namespace std;

#define deb(a)      cout<<" -> "<<#a<<"  "<<a<<endl;
#define oo          (1<<30)
#define ERR         1e-5
#define PRE         1e-8
#define popcount(a) (__builtin_popcount(a))
#define SZ(a)       ((int)a.size())
#define X           first
#define Y           second
#define PB          push_back
#define LL          long long
#define MP          make_pair
#define ISS         istringstream
#define OSS         ostringstream
#define SS          stringstream
#define VS          vector<string>
#define VI          vector<int>
#define VD          vector<double>
#define VLL         vector<long long>
#define IT          ::iterator
#define SI          set<int>
#define CON(a,b)  ((a).find(b)!=(a).end())
#define mem(a,b)    memset(a,b,sizeof(a))
#define memc(a,b)   memcpy(a,b,sizeof(b))
#define accu(a,b,c) accumulate((a),(b),(c))
#define fi(i,a,b)   for(i=a;i<b;i++)
#define fd(i,a,b)   for(i=a;i>b;i--)
#define fii(a,b)    for(i=a;i<b;i++)
#define fdi(a,b)    for(i=a;i>b;i--)
#define fij(a,b)    for(j=a;j<b;j++)
#define fdj(a,b)    for(j=a;j>b;j--)
#define fik(a,b)    for(k=a;k<b;k++)
#define fdk(a,b)    for(k=a;k>b;k--)
#define fil(a,b)    for(l=a;l<b;l++)
#define fdl(a,b)    for(l=a;l>b;l--)
#define ri(i,a)     for(i=0;i<a;i++)
#define rd(i,a)     for(i=a;i>-1;i--)
#define rii(a)      for(i=0;i<a;i++)
#define rdi(a)      for(i=a;i>-1;i--)
#define rij(a)      for(j=0;j<a;j++)
#define rdj(a)      for(j=a;j>-1;j--)
#define rik(a)      for(k=0;k<a;k++)
#define rdk(a)      for(k=a;k>-1;k--)
#define ril(a)      for(l=0;l<a;l++)
#define rdl(a)      for(l=a;i>-1;l--)
#define fore(e,x) for(__typeof(x.begin()) e=x.begin();e!=x.end();++e)
#define EQ(a,b)     (fabs(a-b)<ERR)
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define CROSS(a,b,c,d)  ((b.x-a.x)*(d.y-c.y)-(d.x-c.x)*(b.y-a.y))
#define sqr(a)      ((a)*(a))
#define p2(a)       (1LL<<a)
#define EX(msk,a)   (msk&p2(a))
#define INC(a,b,c)   (b<=a&&a<=c)

const double pi=2*acos(0.);
//const double pi=acos(-1.0);

template<class TT>TT abs(TT a){if(a<0)  return -a;return a;}
template<class ZZ>ZZ max(ZZ a,ZZ b,ZZ c){return max(a,max(b,c));}
template<class ZZ>ZZ min(ZZ a,ZZ b,ZZ c){return min(a,min(b,c));}

//typedef pair< , > pi;
//typedef struct {int x,y,z;}P;
//bool operator < (const P &a,const P &b){return a>b;}
//bool com(P a,P b){return;}
//struct pq{int n,w;  bool operator<(const pq &b)const{return w>b.w;}};

vector<LL> v;

void f(LL d)
{
    if(d>4444444777LL)    return ;
    v.PB(d);
    f(d*10+7);
    f(d*10+4);

}

LL f(LL a,LL b,LL c,LL d)
{
    return max(min(d,b)-max(a,c)+1,0LL);
}

int main()
{
    //freopen("in.in","r",stdin);
    //freopen("ou.out","w",stdout);
    //ios_base::sync_with_stdio(false);
    //std::cout << std::setprecision(13)<<b<<std::endl;

    LL i,j,k,l,tks,ks=1,n,K;
    LL pl,pr,vl,vr,cnt;
    long double by,cn;
    double x;
    f(0);

    sort(all(v));
    //rii(10) deb(v[i]);

    cin>>pl>>pr>>vl>>vr>>k;
//    rii(SZ(v))  if(vl<=v[i] && v[i]<=vr)    {vs=i;break;}
//    rii(SZ(v))  if(pl<=v[i] && v[i]<=pr)    {ps=i;break;}

    by = (vr-vl+1)*(pr-pl+1);

    cnt=0;

    fii(1,SZ(v)-k-4)
    {
        j=f(v[i-1]+1,v[i],pl,pr)*f(v[i+k-1],v[i+k]-1,vl,vr);
        l= f(v[i-1]+1,v[i],vl,vr)*f(v[i+k-1],v[i+k]-1,pl,pr);
        cnt+=j;
        cnt+=l;
        if(k==1 &&j&&l) cnt--;
    }

    cn=cnt;
    //deb(cnt);
    x = cn/by;
    printf("%.13lf\n",x);
    return 0;
}

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

vector<int> v;

void dfs(long long k) {
    if (k > 1000000000) return;
    v.push_back(k);
    dfs(k * 10 + 4), dfs(k * 10 + 7);
}

long long calc(int l, int r, int a, int b) {
    if (a > r || l > b) return 0;
    if (l <= a && r >= b) return b - a + 1;
    if (a <= l && b >= r) return r - l + 1;
    if (b >= r) return r - a + 1;
    else return b - l + 1;
}

int main() {
    dfs(4), dfs(7);
    sort(v.begin(), v.end());
    int pl, pr, vl, vr, k; scanf("%d %d %d %d %d", &pl, &pr, &vl, &vr, &k);
    long long q = (pr - pl + 1) * 1ll * (vr - vl + 1);
    // printf("q = %lld\n", q);
    long long p = 0;
    for (int i = 0, j = i + k - 1; j < v.size(); ++i, ++j) {
        int l = (i == 0 ? 1 : v[i - 1] + 1), r = (j == v.size() - 1 ? 1000000000 : v[j+ 1] - 1);
        p += calc(l, v[i], vl, vr) * calc(v[j], r, pl, pr);
        p += calc(l, v[i], pl, pr) * calc(v[j], r, vl, vr);
        if (k == 1 && v[i] >= vl && v[i] <= vr && v[i] >= pl && v[i] <= pr) --p;
        // printf("p = %lld\n", p);
    }
    printf("%.20lf\n", 1.0 * p / q);
    return 0;
}

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

vector <long long int >v;

int main()
{
	long long int pl,pr,vl,vr,l,r,a,b,c,d,e,f,g,h,ans=0,k,i,j;
	v.push_back(4);
	v.push_back(7);
	i=0;
	while(i<v.size())
	{
		j=v[i];
		if(j*10+4<=1000000000000)
			v.push_back(j*10+4);
		if(j*10+7<=1000000000000)
			v.push_back(j*10+7);
		i++;
	}
	cin>>pl>>pr>>vl>>vr>>k;
	if(k==1)
	{
		for(i=0;i<v.size();i++)
		{
			if(v[i]>=pl && v[i]<=pr && v[i]>=vl && v[i]<=vr)
			ans--;
		}
	}
	for(i=0;i<v.size()-k;i++)
	{
		if(i==0)
			a=1;
		else
			a=v[i-1]+1;
		b=v[i];
		c=v[i+k-1];
		d=v[i+k]-1;
		e=max(a,pl);
		f=min(b,pr);
		g=max(f-e+1,0LL);
		e=max(c,vl);
		f=min(d,vr);
		h=max(f-e+1,0LL);
		ans+=g*h;
		e=max(a,vl);
		f=min(b,vr);
		g=max(f-e+1,0LL);
		e=max(c,pl);
		f=min(d,pr);
		h=max(f-e+1,0LL);
		ans+=g*h;
	}
	//cout<<ans<<" ";
	double finans=(double)ans/((double)((pr-pl+1)*(vr-vl+1)));
	printf("%.9lf",finans);
	return 0;
}

//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

set<int>s;
void dfs(int num)
{
    if(num>1e10)
        return ;
    s.insert(num);
    dfs(num*10+4);
    dfs(num*10+7);
}
int32_t main()
{
    IOS;
    dfs(4);dfs(7);
    vector<int>v;
    for(int i:s)
        v.push_back(i);
    int pl,pr,vl,vr,k;
    cin>>pl>>pr>>vl>>vr>>k;
    int total=0;
    for(int i=0;i<1030;i++)
    {
        int num1=v[i];
        int num2=v[i+k-1];

        int l1,r1,l2,r2;
        l1= (i==0)?pl-1:max(v[i-1],pl-1);
        r1= min(pr,num1);
        l2= max(num2-1,vl-1);
        r2= min(vr,v[i+k]-1);
        if(!(l1>r1 || l2>r2))
            total+=(r1-l1)*(r2-l2);

        l1= (i==0)?vl-1:max(v[i-1],vl-1);
        r1= min(vr,num1);
        l2= max(num2-1,pl-1);
        r2= min(pr,v[i+k]-1);
        if(!(l1>r1 || l2>r2))
            total+=(r1-l1)*(r2-l2);
    }
    if(k==1)
        for(int i=0;i<1030;i++)
            if(v[i]>=vl && v[i]<=vr && v[i]>=pl && v[i]<=pr)
                total--;
    cout<<fixed<<setprecision(12)<<total*1.0/(pr-pl+1)/(vr-vl+1)<<endl;
}

#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <iostream>
#include <iterator>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <sstream>

using namespace std;

#define REP(i,n) for (int i=0,_n=(n); i < _n; i++)
#define REPD(i,n) for (int i=(n)-1; i >= 0; i--)
#define FOR(i,a,b) for (int _b=(b), i=(a); i <= _b; i++)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;i--)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))

#define CLEAR(x) memset(x,0,sizeof x);
#define CLEARA(x) memset(&x,0,sizeof x);
#define FILL(x,v) memset(x,v,sizeof x);
#define FILLA(x,v) memset(&x,v,sizeof x);

#define VAR(a,b) __typeof(b) a=(b)
#define FOREACH(it,c) for(VAR(it,(c).begin());it!=(c).end();++it)

#define REVERSE(c) reverse(ALL(c))
#define UNIQUE(c) SORT(c),(c).resize(unique(ALL(c))-(c).begin())
#define INF 0x7fffffff
#define X first
#define Y second
#define pb push_back
#define SZ(c) (int)(c).size()
#define MP make_pair
#define eps 1.0e-11
const double pi = acos(-1.0);

typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;

int a1,a2,b1,b2,k;

LL inter(int a, int b, int c, int d)
{
	return max(0,min(b,d)-max(a,c)+1);
}

int main()
{
	//freopen("b.in","r",stdin);
	//freopen(".out","w",stdout);

	scanf("%d%d%d%d%d",&a1,&a2,&b1,&b2,&k);
	VI d;
	FOR(len,1,9) REP(mask,1<<len)
	{
		int x = 0;
		REP(i,len)
			x = x*10 + (mask&(1<<i) ? 4 : 7);
		d.pb(x);
	}
	d.pb(0);
	d.pb(1000111000);
	SORT(d);
	LL res = 0;
	REP(i,SZ(d)) if (i>0)
	{
		if (i + k-1 >= SZ(d)-1) continue;
		res += inter(d[i-1]+1, d[i], a1, a2)*inter(d[i+k-1],d[i+k]-1, b1, b2);
		res += inter(d[i-1]+1, d[i], b1, b2)*inter(d[i+k-1],d[i+k]-1, a1, a2);
		if (k==1 && a1 <= d[i] && d[i] <= a2 && b1 <= d[i] && d[i] <= b2)
			--res;
	}

	printf("%.12lf\n",res/(double)(a2-a1+1)/(double)(b2-b1+1));
	return 0;
}

//In the Name of God
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long LL;

LL p1, p2, v1, v2, k, MAX = 1000 * 1000 * 1000;
double ans;
vector <LL> lucky;

void gen(LL cur){
    if(cur > MAX)
        return ;
    lucky.push_back(cur);

    gen(cur * 10 + 4);
    gen(cur * 10 + 7);
}

double count(LL st, LL en, LL ind){
    if(ind == 0){
        if(st > p2 or p1 > en) return 0;
        return (min(p2, en) - max(p1, st) + 1) / double(p2 - p1 + 1);
    }
    else{
        if(st > v2 or v1 > en) return 0;
        return (min(v2, en) - max(v1, st) + 1) / double(v2 - v1 + 1);
    }
}

void add(LL st, LL en){
    LL st1, en1;
    if(st == 0) st1 = 0;
    else st1 = lucky[st - 1] + 1;

    if(en == lucky.size() - 1) en1 = MAX;
    else en1 = lucky[en + 1] - 1;

    st = lucky[st];
    en = lucky[en];

    ans += count(st1, st, 0) * count(en, en1, 1);
    ans += count(st1, st, 1) * count(en, en1, 0);
    if(st == en and st >= p1 and st <= p2 and st >= v1 and st <= v2)
        ans -= 1.0 / ((p2 - p1 + 1) * (v2 - v1 + 1));
}

int main(){
    cin >> p1 >> p2;
    cin >> v1 >> v2;
    cin >> k;

    gen(4);
    gen(7);

    sort(lucky.begin(), lucky.end());

    for(LL i = 0 ; i + k - 1 < lucky.size() ; i++)
        add(i, i + k - 1);
    cout.precision(9);
    cout << fixed << ans << endl;
    return 0;
}

/*********************************************************************\
   |--\        ---       /\        |-----------| -----   /-------|    |
   |   \        |       /  \       |               |    /             |
   |    \       |      /    \      |               |   |              |
   |     \      |     /      \     |               |   |----|         |
   |      \     |    / ------ \    |-------|       |        |-----|   |
   |       \    |   /          \   |               |              |   |
   |        \   |  /            \  |               |              /   |
  ---        -------            ------           ----- |---------/    |
                                                                      |
    codeforces = nfssdq  ||  topcoder = nafis007                      |
    mail = nafis_sadique@yahoo.com || nfssdq@gmail.com                |
    IIT,Jahangirnagar University(41)                                  |
                                                                      |
**********************************************************************/

#include <bits/stdc++.h>

using namespace std;

#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)

//cout << fixed << setprecision(20) << p << endl;

template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

vector < LL > vc;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    LL a,b = 0,c,d = 0,e,f = 0,g,h = 0,x,y,z = 0;
    vc.pb(0);
    FOR(i, 1, 10){
        REP(j, 1<<i){
            a = 0;
            REP(k, i){
                a *= 10;
                if(j & 1<<k) a += 7;
                else a += 4;
            }
            vc.pb(a);
        }
    }
    vc.pb(1e9);
    vsort(vc);
    LL pl, pr, vl, vr;
    cin >> pl >> pr >> vl >> vr >> a;
    if(pl == pr && vl == vr)
    f = 0;
    LL tot = (pr - pl + 1) * (vr - vl + 1);
    FOR(i, 1, vc.size() - 1){
        if(i + a >= vc.size()) break;
        b = vc[i], c = vc[i + a - 1];
        g = h = 0;
        if(b >= vl && vc[i-1] < vr && c <= pr && vc[i+a] > pl){
            g = (min(b,vr) - max(vl, vc[i-1]+1) + 1) * (min(pr, vc[i+a]-1) - max(c,pl) + 1);
        }
        if(b >= pl && vc[i-1] < pr && c <= vr && vc[i+a] > vl){
            h = (min(b,pr) - max(pl, vc[i-1]+1) + 1) * (min(vr, vc[i+a]-1) - max(c,vl) + 1);
        }
        f += g + h;
        if(g && h && a == 1) f--;
    }
    cout << fixed << setprecision(10) << (double)f/(double)tot << endl;
}

#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <list>
#include <sstream>

using namespace std;

#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define ford(i, n) for(int i = int(n)-1; i >= 0; --i)
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define for1(i, n) for(int i = 1; i <= int(n); ++i)
#define pb push_back
#define mp make_pair
#define sz(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define X first
#define Y second
template<typename T> T abs(T a) { return a < 0 ? -a : a; }
template<typename T> T sqr(T a) { return a * a; }

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const int INF = int(1E9)+7;
const ld EPS = 1E-9;
const ld PI = acos(-1.0);

vector<int> ok;

void gen(li v){
    if(v > INF) return;
    if(v > 0)
        ok.pb(v);

    gen(v * 10 + 4);
    gen(v * 10 + 7);
}

li leng(li L, li R){
    if(L > R) return 0;
    return R-L+1;
}

int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    gen(0);

    sort(all(ok));

    /*
    cerr << "Luck: " << endl;
    forn(i, sz(ok))
        cerr << ok[i] << " ";
    cerr << endl;*/

    int p1, p2, v1, v2, k;
    cin >> p1 >> p2 >> v1 >> v2 >> k;

    ld p = 0;

    forn(i, sz(ok)){
        int j = i+k-1;

        if(j >= sz(ok)) break;

        int lfMin = i == 0 ? 1 : ok[i-1]+1;
        int rgMin = ok[i];

        int lfMax = ok[j],
            rgMax = j == sz(ok)-1 ? INF : ok[j+1]-1;

        ld pcur = 0;

        if(k > 1){
            {
                int L1 = max(lfMin, p1), R1 = min(rgMin, p2);
                int L2 = max(lfMax, v1), R2 = min(rgMax, v2);
                pcur += leng(L1, R1) / ld(leng(p1, p2)) * leng(L2, R2) / ld(leng(v1, v2));
            }
            {
                int L1 = max(lfMin, v1), R1 = min(rgMin, v2);
                int L2 = max(lfMax, p1), R2 = min(rgMax, p2);
                pcur += leng(L2, R2) / ld(leng(p1, p2)) * leng(L1, R1) / ld(leng(v1, v2));
            }
        }else{
            li good = 0;
            {
                int L1 = max(lfMin, p1), R1 = min(rgMin, p2);
                int L2 = max(lfMax, v1), R2 = min(rgMax, v2);
                good += leng(L1, R1) * leng(L2, R2);
            }
            {
                int L1 = max(lfMin, v1), R1 = min(rgMin, v2);
                int L2 = max(lfMax, p1), R2 = min(rgMax, p2);
                good += leng(L2, R2) * leng(L1, R1);
            }
            if(v1 <= ok[i] && ok[i] <= v2 && p1 <= ok[i] && ok[i] <= p2)
                good--;

            pcur = good / ld(leng(p1, p2) * leng(v1, v2));
        }

        p += pcur;
    }

    cout.precision(10); cout << fixed;
    cout << p << endl;

    return 0;
}

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <deque>
#include <bitset>
#include <cstring>

#define f first
#define s second
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define mp make_pair
#define y0 eto
#define y1 mezhdy
#define y2 nami
#define left ksfjgksjfd
#define right fksfjgksjfd

using namespace std;

ll l1,l2,r1,r2,k;
vector<ll> luck;

ll inter(ll x1,ll y1,ll x2,ll y2)
{
    return max(0LL,min(y1,y2)-max(x1,x2)+1);
}

int main()
{
    ios_base::sync_with_stdio(0);
    //freopen("INPUT.txt","r", stdin);
    luck.pb(0);
    for(int len=1;len<=9;len++)
    {
        for(int i=0;i<(1<<len);i++)
        {
            ll cur=0;
            for(int j=0;j<len;j++)
                if(i&(1<<j))
                    cur=10*cur+7;
                else
                    cur=10*cur+4;
            luck.pb(cur);
        }
    }
    luck.pb(1000000009);
    sort(all(luck));
    cin>>l1>>r1>>l2>>r2>>k;

    ll len1=r1-l1+1;
    ll len2=r2-l2+1;

    double ans=0;

    for(int i=1;i+k<luck.size();i++)
    {
        ll x1=luck[i-1]+1;
        ll y1=luck[i];
        ll x2=luck[i+k-1];
        ll y2=luck[i+k]-1;

        ll inter1=inter(x1, y1, l1, r1);
        ll inter2=inter(x2, y2, l2, r2);

        ans+=1.0*inter1/len1*inter2/len2;

        inter1=inter(x2, y2, l1, r1);
        inter2=inter(x1, y1, l2, r2);

        ans+=1.0*inter1/len1*inter2/len2;

        if(k==1 && inter2 && inter1)
        {
            ans-=1.0/(len1*len2);
        }
    }

    cout<<fixed<<setprecision(10)<<ans<<endl;

}

#include <iostream>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#define INFY 1000000000
#define MAXN 100000
using namespace std;

int f[10000];

int next(int n){
    if(n==0) return 4;
    if(n%10==4) return (n/10)*10+7;
    return next(n/10)*10+4;
}

int main(){
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int pl, pr, vl, vr, k, i, j;
    int l1, l2, r1, r2;
    long long tu = 0;
    scanf("%d", &pl);
    scanf("%d", &pr);
    scanf("%d", &vl);
    scanf("%d", &vr);
    scanf("%d", &k);
    long long mau = (long long)(pr-pl+1)*(vr-vl+1);
    f[0]=0;
    for(i=1; f[i-1]<=777777774 ;i++) f[i] = next(f[i-1]);
    f[i] = 1000000001;
    //for(j=0; j<i; j++) cout<<f[j]<<" ";
    //chon p<=v
    for(j=1; k+j-1<i; j++){
        if(f[j-1]>=pl) l1=f[j-1]+1;
        else l1=pl;
        if(f[j]<pr) r1=f[j];
        else r1=pr;

        if(f[k+j-1]>=vl) l2=f[k+j-1];
        else l2=vl;
        if(f[k+j]<=vr) r2=f[k+j]-1;
        else r2=vr;

        tu += (long long)max(r1-l1+1, 0)*max(r2-l2+1, 0);
    }

    //chon p>=v
    for(j=1; k+j-1<i; j++){
        if(f[j-1]>=vl) l2=f[j-1]+1;
        else l2=vl;
        if(f[j]<vr) r2=f[j];
        else r2=vr;

        if(f[k+j-1]>=pl) l1=f[k+j-1];
        else l1=pl;
        if(f[k+j]<=pr) r1=f[k+j]-1;
        else r1=pr;

        tu += (long long)max(r1-l1+1, 0)*max(r2-l2+1, 0);
    }

    //k=1
    if(k==1){
        for(j=1; j<i; j++) if(f[j]<=pr && f[j]>=pl && f[j]<=vr && f[j]>=vl) tu--;
    }

    double kq = (double)tu / mau;

    printf("%.9lf", kq);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
/*
#define cin fin
#define cout fout

ifstream fin("input.txt");
ofstream fout("output.txt");*/

#define SI(x) cin>>x
#define DI(x, y) cin>>x>>y
#define TI(x, y, z) cin>>x>>y>>z
#define FI(w, x, y, z) cin>>w>>x>>y>>z

#define SO(x) cout<<x<<endl
#define DO(x, y) cout<<x<<" "<<y<<endl
#define TO(x, y, z) cout<<x<<" "<<y<<" "<<z<<endl
#define FO(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl

#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

#define pr pair<lli, lli>
//#define V(x) vector<x>
#define pb(x) push_back(x)
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend());
#define mp(x, y) make_pair(x, y)
#define fi first
#define se second
#define mll(x, y) map<lli x, lli y>

#define F(i, a, n) for(i=a;i<n;i++)
#define B(i, a, n) for(i=n-1;i>=a;i--)

#define mod 1000000007
#define pi 3.141592653589793238

//GCD
lli gcd(lli a, lli b){
    if(b < a)    {
        lli temp = a;
        a = b;
        b = temp;
    }
    if(a == 0){
        return b;
    }
    return gcd(b%a,a);
}
lli max(lli a, lli b){
    if(a>b)
        return a;
    return b;
}
//LCM
lli lcm(lli a, lli b){
    return (a*b/gcd(a,b));
}

//Factorial
lli fact(lli x){
    lli ans = 1;
    if(x == 0){
        return 1;
    }
    while(x > 0){
        ans = (ans*x)%mod;
        x--;
    }
    return ans%mod;
}
//C(n, r)
lli comb(lli n, lli r){
    lli x=fact(r), y=fact(n-r);
    x=(x*y)%mod;
    if(fact(n)>x)
        return fact(n)/x;
    return (fact(n)+mod)/x;
}
lli power(lli a, lli p)
{
    lli ans = 1;
    while(p > 0)
    {
        if(p%2)
        {
            ans *= a;
            ans %= 1000000007;
        }
        a*=a;
        a%=1000000007;
        p/=2;
    }
    return ans%1000000007;
}
float dist(lli x1, lli y1, lli x2, lli y2){
    return sqrt(1.0*(x1-x2)*(x1-x2) + 1.0*(y1-y2)*(y1-y2));
}
//binary of a number
vector <lli> getbinary(lli x){
    vector <lli> bin(20000,0);
    lli iter = 0;
    while(x > 0){
        if(x%2 == 1){
            bin[iter] = 1;
        }
        else{
            bin[iter] = 0;
        }
        iter++;
        x/=2;
    }
    return bin;
}
lli fn(lli l1, lli r1, lli l2, lli r2){
    l1=max(l1, l2);
    r1=min(r1, r2);
    return max(r1-l1+1, 0ll);
}
int main(){
    FASTER;
    lli l1, r1, l2, r2, k=0, a[5000], i, mi, ma, d=0;
    a[0]=0;
    for(i=1;i<5000;i+=2){
        a[i]=a[k]*10+4;
        a[i+1]=a[k]*10+7;
        k++;
    }
    //F(i, 0, 20)
    //    SO(a[i]);
    FI(l1, r1, l2, r2);
    SI(k);
    F(i, 1, 5000-k){
        mi=fn(a[i-1]+1, a[i], l2, r2)*fn(a[i+k-1], a[i+k]-1, l1, r1);
        ma=fn(a[i-1]+1, a[i], l1, r1)*fn(a[i+k-1], a[i+k]-1, l2, r2);
        d+=ma+mi;
        if(k==1 && mi>0 && ma>0)
            d--;
    }
    lli all=(r1-l1+1)*(r2-l2+1);
    cout<<fixed<<setprecision(12)<<1.0*d/all;
}

#define _CRT_SECURE_NO_DEPRECATE
#include <algorithm>  ///////////////////////////////
#include <cmath>      // Kyiv NU BZFlags           //
#include <cstdio>     // official template.        //
#include <cstdlib>    //                     WE    //
#include <cstring>    // PVA! (eng. TEA!)  HAVE    //
#include <ctime>      //                     SOME  //
#include <fstream>    // T-shirt design    MORE    //
#include <iostream>   // approved by        EMPTY  //
#include <map>        // Ostap Korkuna   SPACE     //
#include <set>        // +X(XXX)XXX-XX-XX     HERE //
#include <sstream>    //                           //
#include <stack>      // Please don't exceed       //
#include <string>     // 80 chars per line.        //
#include <vector>     // And make comments, bitch! //
#include <queue>      ///////////////////////////////
#pragma comment(linker, "/STACK:16777216")
using namespace std;
#define all(c) (c).begin(), (c).end()
#define C(a) memset((a),0,sizeof(a))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for(int i = (a); i >= (b); i--)
#define INF 1000000000
#define ll long long
#define L(s) (int)((s).size())
#define mp make_pair  //make love not pairs
#define pb push_back  //Ever heard KADR singing that?
#define pdd pair<double,double>              //   |
#define pii pair<int,int>                    //   V
#define pi 3.1415926535897932384626433832795028841971
#define ppb pop_back              ///////////////////
#define rep(i,n) FOR(i,1,(n))     //                //
#define rept(i,n) FOR(i,0,(n)-1)  //     .--._____, //
#define rp rept                   // .-='=='==-, "  //
#define SORT(c) sort(all(c))      // (O_o_o_o_o_O)  //
#define sqr(a) (a)*(a)            //                //
#define VI vector<int>            //  Please take   //
#define x first                 //   a moment to  //
#define y second                //  appreciate    //
//   how AWESOME  //
//    we are!     //
////////////////////
#define UN(v) sort((v).begin(),(v).end()),v.erase(unique(v.begin(),v.end()),v.end())
#define problem ""

int a1,b1,a2,b2,k;
VI a;

inline bool good(int x)
{
	while(x)
	{
		if (x%10!=4 && x%10!=7) return 0;
		x/=10;
	}
	return 1;
}
inline ll naive(int a1,int a2,int b1,int b2,int k)
{
	int tot=0;
	for(int i=a1;i<=a2;++i)
		for(int j=b1;j<=b2;++j)
		{
			int cnt=0;
			for(int x=min(i,j); x<=max(i,j); ++x)
				if (good(x))
					cnt++;
			if (cnt==k)
				tot++;
		}
		return tot;
}
inline ll solve(int a1,int a2, int b1,int b2,int k)
{
	a.clear();
	for(int len=1;len<10;++len)
		rp(mask,1<<len)
	{
		int val=0;
		rp(j,len)
			if (mask&(1<<j))
				val=val*10+4;
			else
				val=val*10+7;
		a.pb(val);
	}
	sort(all(a));
	ll good=0;
	for(int i=0;i+k<=L(a);++i)
	{
		rp(step,2)
		{
			if (a1<=a[i] && b2>=a[i+k-1])
			{
				if (i && a2<=a[i-1]) goto fin;
				if (i+k<L(a) && b1>=a[i+k]) goto fin;
				int da,ua,db,ub;
				da=a1;if (i) da=max(da, a[i-1]+1);
				ua=min(a[i], a2);

				db=max(a[i+k-1], b1);
				ub=b2;if (i+k<L(a)) ub=min(ub, a[i+k]-1);
				good+=(ll)(ua-da+1)*(ub-db+1);
			}
fin:;
			swap(a1,b1);
			swap(a2,b2);
		}
	}
	if (k==1)
	{
		rp(i,L(a))
			if (a1<=a[i] && a[i]<=a2)
				if (b1<=a[i] && a[i]<=b2)
					good--;
	}
	return good;
}
int main()
{
	cin>>a1>>a2>>b1>>b2>>k;
	ll total=(ll)(a2-a1+1)*(b2-b1+1);
	printf("%0.9lf\n",(double)solve(a1,a2,b1,b2,k)/total);

}

/*
ID   : mnlm1991
PROG : D
LANG : C++
*/

#include<map>
#include<set>
#include<list>
#include<stack>
#include<queue>
#include<cmath>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;

#define PB push_back
#define MP make_pair

#define REP(i, n) for(i=0;i<(n);i++)
#define FOR(i, l, h) for(i=(l);i<=(h);i++)
#define FORD(i, h, l) for(i=(h);i>=(l);i--)
#define MM(x, v) memset(x, v, sizeof(x))

typedef vector <int> VI;
typedef vector <double> VD;
typedef vector <string> VS;
typedef pair <int, int> PII;
typedef long long LL;

const int oo = 1000000000;
__int64 lucky[10001];
int l = 0;
void DFS(__int64 x)
{
        lucky[l++] = x * 10 + 4;
        if (lucky[l - 1] <= oo)
        {
                DFS(lucky[l - 1]);
        }
        else
        {
                l--;
        }
        lucky[l++] = x * 10 + 7;
        if (lucky[l - 1] <= oo)
        {
                DFS(lucky[l - 1]);
        }
        else
        {
                l--;
        }
}
int main()
{
        int i;
        lucky[0] = -1;
        l = 1;
        DFS(0);
        sort(lucky, lucky + l);
        lucky[l] = oo;
        __int64 pl, pr;
        __int64 vl, vr;
        int k;
        while (scanf("%I64d%I64d%I64d%I64d%d", &pl, &pr, &vl, &vr, &k) != EOF)
        {
                int i;
                int j;
                double sum = 0.0;
                FOR(i, 1, l - k)
                {
                        __int64 ii = lucky[i];
                        j = i + k - 1;
                        __int64 jj = lucky[j];
                        //printf("%d %d\n", ii, jj);
                        //system("pause");
                        if (ii >= pl && lucky[i - 1] + 1 <= pr &&
                        jj <= vr && lucky[j + 1] - 1 >= vl)
                        {
                                sum += 1.0 *(min(pr, ii) - max(pl, lucky[i - 1] + 1) + 1)*(min(vr, lucky[j + 1] - 1) - max(jj, vl) + 1);
                        }
                        if (ii >= vl && lucky[i - 1] + 1 <= vr &&
                        jj <= pr && lucky[j + 1] - 1 >= pl)
                        {
                                sum += 1.0*(min(vr, ii) - max(vl, lucky[i - 1] + 1) + 1)*(min(pr, lucky[j + 1] - 1) - max(jj, pl) + 1) - (k == 1);
                        }
                }
                //printf("%lf\n", sum);
                printf("%.20lf\n", sum / (pr - pl + 1.0) / (vr - vl + 1.0));
        }
        return 0;
}

#include<iostream>
#include<set>
#include<map>
#include<functional>
#include<queue>
#include<string.h>
#include<stdio.h>
#include<iomanip>
#include<stdlib.h>
#include<math.h>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<bitset>
#include<fstream>
typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define sz(a) (int)a.size()
#define sqr(x) ((x) * (x))
#define pi pair<ll, ll>
#define mk(a, b) make_pair(a, b)
#define nextI nextInt()
#define nextD nextDouble()
#define nextL nextLong()
#define nextC nextChar()
#define line newLine()
int nextInt(){ int x; scanf("%d", &x); return x; }
double nextDouble(){ double x; scanf("%lf", &x); return x; }
ll nextLong(){ ll x; scanf("%I64d", &x); return x; }
char nextChar(){ char x; scanf("%c", &x); return x; }
void newLine(){ printf("\n"); }
int gcd(int a, int b){ return b == 0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b){ return (a*b) / gcd(a, b); }
ll powM(ll a, ll b, ll MOD){ ll x = 1, y = a; while (b > 0){ if (b % 2 == 1){ x = (x*y); if (x>MOD) x %= MOD; }y = (y*y); if (y>MOD) y %= MOD; b /= 2; }return x; }
int countBitSet(ll n){ int ans = 0;  while (n != 0){ n -= (n & -n); ++ans; } return ans; }
ll mod = ll(1e9 + 7);
ll mod2 = 1e9 + 9;
const int N = 100100;
const int M = 100;
const double eps = (double)1e-6;
using namespace std;

vector<ll> v;
void bfs(){
	queue<ll> q;
	q.push(4);
	q.push(7);
	while (!q.empty()){
		ll x = q.front();
		q.pop();
		v.push_back(x);
		ll v1 = x * 10 + 4;
		ll v2 = x * 10 + 7;
		if (v1 < 1e9) q.push(v1);
		if (v2 < 1e9) q.push(v2);
	}
}

ll intersect(ll x1, ll y11, ll x2, ll y2){
	ll mx = max(x1, x2);
	ll mn = min(y11, y2);
	if (mn < mx) return 0;
	else return (mn - mx + 1);
}

pair<ll, ll> intersect2(ll x1, ll y11, ll x2, ll y2){
	ll mx = max(x1, x2);
	ll mn = min(y11, y2);
	if (mn < mx) return mk(-1, -1);
	else return mk(mx, mn);
}
int main(){
#ifdef HOME
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ll l1, r1, l2, r2, k;
	cin >> l1 >> r1 >> l2 >> r2 >> k;
	bfs();
	int n = v.size();
	if (n < k){
		puts("0");
	}
	ll ans = 0;
	for (int i = 0; i <= n - k; i++){
		ll x1 = v[i] == 4 ? 1 : v[i - 1] + 1;
		ll y11 = v[i];
		ll x2 = v[i + k - 1];
		ll y2 = (i + k == n) ? (ll)1e9 : v[i + k] - 1;

		ans += intersect(x1, y11, l1, r1) * intersect(x2, y2, l2, r2);
		ans += intersect(x1, y11, l2, r2) * intersect(x2, y2, l1, r1);
		pair<ll, ll> p1 = intersect2(x1, y11, l1, r1);
		pair<ll, ll> p2 = intersect2(x2, y2, l2, r2);

		if (p1.first != -1 && p2.first != -1)
			ans -= intersect(p1.first, p1.second, p2.first, p2.second);
	}

	cout << fixed << setprecision(10) << ((double)1.0 *	ans) / ((double) 1.0 * (r1 - l1 + 1) * (r2 - l2 + 1)) << endl;
}

/* Author : RISHAV GOYAL */

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

#define LL long long int
#define UL unsigned long long int

#define imax INT_MAX
#define imin INT_MIN
#define LLmax LLONG_MAX
#define LLmin LLONG_MIN

#define FOR(i,a,b) for(int i= (int)a; i<= (int)b; i++)
#define rep(i,n) for(int i= int(1); i<= (int)n; i++)
#define FORd(i,a,b,d) for(int i=(int)a; i<= (int)b; i+=(int)d)

#define pr() printf("Reached here 1...\n");
#define pr1() printf("Reached here 2...\n");

#define CLR(a) memset(a,0,sizeof(a));
#define SET(a) memset(a,-1,sizeof(a));

#define str strlen
#define pb(x) push_back(x)
#define mp make_pair
#define ii pair<int,int>
#define ll pair<LL,LL>

#define F first
#define S second
#define gcd(a,b) __gcd(a,b)

#define mod int(1e9 + 7)
#define MAX int(1e5 + 10)

#define si(a) scanf("%d",&a);

#define VI vector<int>
#define VL vector<LL>
#define VS vector<string>
#define VC vector<char>

LL powmod(LL a,int b,int n){LL rm=1;while (b){if (b % 2) { rm = (rm * a) % n; }a = (a * a) % n;b /= 2;}return rm;}

int k,lucky[MAX], n = 0 ,a[10][500000],ct[10]={0};
double ans = 0.0;
LL p1,p2,v1,v2,l1,l2,r1,r2,i1,i2,i3,i4;
void brute(int level,int numbersofar){
	if(level>1) a[level-1][++ct[level-1]] = numbersofar;
	if(level == 10){
		return ;
	}
	brute(level+1,numbersofar*10+4);
	brute(level+1,numbersofar*10+7);
}

int main()
{
	cin >> p1 >> p2 >> v1 >> v2 >> k;
	double pair = (p2 - p1 + 1) * ( v2 - v1 + 1);

	brute(1,0); // length,level,numbersofar
	for(int i = 1; i <= 9;++i){
		for(int j = 1; j <= ct[i];++j){
			lucky[++n] = a[i][j];
		}
	}
	lucky[0] = 0;
	for(int i = 1; i <= n-k+1;++i){
		l1 = lucky[i-1]+1, l2 = lucky[i];
		if(i == n-k+1){
			r1 = lucky[i+k-1], r2 = 1e9;
		}
		else{
			r1 = lucky[i+k-1], r2 = lucky[i+k] - 1;
		}

		// v,p
		i1 = max(l1 , v1);
		i2 = min(l2, v2);
		i3 = max(r1, p1);
		i4 = min(r2, p2);

		if(i2>=i1 && i4>=i3){
			//cout << lucky[i] << " ==>> " << i1 << " " << i2  << " " << i3 << " " << i4 << endl;
			ans += ((i4 - i3 + 1)  *( i2 - i1 + 1) * 1.0) / pair;
		}

		i1 = max(r1, v1);
		i2 = min(r2, v2);
		i3 = max(l1, p1);
		i4 = min(l2, p2);
		if(i2>=i1 && i4>=i3){
					//cout << lucky[i] << " ==2>> " << i1 << " " << i2  << " " << i3 << " " << i4 << endl;

			ans += ((i4 - i3 + 1)  *( i2 - i1 + 1) * 1.0) / pair;
		}

		if(k==1 && lucky[i]>=v1 && lucky[i]<=v2 && lucky[i]>=v1 && lucky[i]<=v2 ) ans -= 1.0 / pair;
	}
	//cout << ans << endl;
	printf("%.10lf\n", ans);

	return 0;
}

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef long double ld;

const int Inf = 1000000005;

vector <int> V;
ll pl, pr, vl, vr, k;
ll good;

void Gen(int lft, int num)
{
     if (!lft) V.push_back(num);
     else {
          Gen(lft - 1, 10 * num + 4);
          Gen(lft - 1, 10 * num + 7);
     }
}

ll getP(ll l, ll r)
{
    ll curl = max(l, pl), curr = min(r, pr);
    ll res = curr - curl + 1LL;
    if (res <= 0) return 0;
    return res;
}

ll getV(ll l, ll r)
{
    ll curl = max(l, vl), curr = min(r, vr);
    ll res = curr - curl + 1LL;
    if (res <= 0) return 0;
    return res;
}

int main()
{
    V.push_back(0);
    for (int i = 1; i < 10; i++)
       Gen(i, 0);
    V.push_back(Inf);
    cin >> pl >> pr >> vl >> vr >> k;
    for (int i = 1; i + k < V.size(); i++)
       if (k == 1)
          good += getP(V[i - 1] + 1, V[i]) * getV(V[i + k - 1], V[i + k] - 1) +
                  getP(V[i + k - 1], V[i + k] - 1) * getV(V[i - 1] + 1, V[i]) -
                  getP(V[i], V[i]) * getV(V[i], V[i]);
       else good += getP(V[i - 1] + 1, V[i]) * getV(V[i + k - 1], V[i + k] - 1) +
                    getP(V[i + k - 1], V[i + k] - 1) * getV(V[i - 1] + 1, V[i]);
    cout << fixed << setprecision(20) << ld(good) / ld(ll(pr - pl + 1) * ll(vr - vl + 1)) << endl;
    return 0;
}

/** ` Micro Mezzo Macro Flation -- Overheated Economy ., **/

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define DWN(i, b, a) for (int i=int(b-1);i>=int(a);--i)
#define REP_1(i, n) for (int i=1;i<=int(n);++i)
#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)
#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)
#define REP_C(i, n) for (int n____=int(n),i=0;i<n____;++i)
#define FOR_C(i, a, b) for (int b____=int(b),i=a;i<b____;++i)
#define DWN_C(i, b, a) for (int a____=int(a),i=b-1;i>=a____;--i)
#define REP_N(i, n) for (i=0;i<int(n);++i)
#define FOR_N(i, a, b) for (i=int(a);i<int(b);++i)
#define DWN_N(i, b, a) for (i=int(b-1);i>=int(a);--i)
#define REP_1_C(i, n) for (int n____=int(n),i=1;i<=n____;++i)
#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i<=b____;++i)
#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i>=a____;--i)
#define REP_1_N(i, n) for (i=1;i<=int(n);++i)
#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)
#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)
#define REP_C_N(i, n) for (n____=int(n),i=0;i<n____;++i)
#define FOR_C_N(i, a, b) for (b____=int(b),i=a;i<b____;++i)
#define DWN_C_N(i, b, a) for (a____=int(a),i=b-1;i>=a____;--i)
#define REP_1_C_N(i, n) for (n____=int(n),i=1;i<=n____;++i)
#define FOR_1_C_N(i, a, b) for (b____=int(b),i=a;i<=b____;++i)
#define DWN_1_C_N(i, b, a) for (a____=int(a),i=b;i>=a____;--i)

#define DO(n) while(n--)
#define DO_C(n) int n____ = n; while(n____--)
#define TO(i, a, b) int s_=a<b?1:-1,b_=b+s_;for(int i=a;i!=b_;i+=s_)
#define TO_1(i, a, b) int s_=a<b?1:-1,b_=b;for(int i=a;i!=b_;i+=s_)
#define SQZ(i, j, a, b) for (int i=int(a),j=int(b)-1;i<j;++i,--j)
#define SQZ_1(i, j, a, b) for (int i=int(a),j=int(b);i<=j;++i,--j)
#define REP_2(i, j, n, m) REP(i, n) REP(j, m)
#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)

#define ALL(A) A.begin(), A.end()
#define LLA(A) A.rbegin(), A.rend()
#define CPY(A, B) memcpy(A, B, sizeof(A))
#define INS(A, P, B) A.insert(A.begin() + P, B)
#define ERS(A, P) A.erase(A.begin() + P)
#define BSC(A, X) find(ALL(A), X) // != A.end()
#define CTN(T, x) T.find(x) != T.end()
#define SZ(A) int(A.size())
#define PB push_back
#define MP(A, B) make_pair(A, B)

#define Rush int T____; RD(T____); DO(T____)
#pragma comment(linker, "/STACK:36777216")
#pragma GCC optimize ("O2")
#define Ruby system("ruby main.rb")
#define Haskell system("runghc main.hs")
#define Pascal system("fpc main.pas")

typedef long long LL;
typedef double DB;
typedef unsigned UINT;
typedef unsigned long long ULL;

typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<DB> VD;
typedef set<int> SI;
typedef set<string> SS;
typedef set<LL> SL;
typedef set<DB> SD;
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef map<LL, int> MLI;
typedef map<DB, int> MDI;
typedef map<int, bool> MIB;
typedef map<string, bool> MSB;
typedef map<LL, bool> MLB;
typedef map<DB, bool> MDB;
typedef pair<int, int> PII;
typedef pair<int, bool> PIB;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<VII> VVII;
typedef set<PII> SII;
typedef map<PII, int> MPIII;
typedef map<PII, bool> MPIIB;

/** I/O Accelerator **/

/* ... :" We are I/O Accelerator ... Use us at your own risk ;) ... " .. */

template<class T> inline void RD(T &);
template<class T> inline void OT(const T &);

template<class T> inline T& _RD(T &x){ RD(x); return x;}
inline int RD(){ int x; RD(x); return x;}
inline LL RD_LL(){ LL x; RD(x); return x;}
inline DB RD_DB(){ DB x; RD(x); return x;}

template<class T0, class T1> inline void RD(T0 &x0, T1 &x1){RD(x0), RD(x1);}
template<class T0, class T1, class T2> inline void RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2);}
template<class T0, class T1, class T2, class T3> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6);}
template<class T0, class T1> inline void OT(T0 &x0, T1 &x1){OT(x0), OT(x1);}
template<class T0, class T1, class T2> inline void OT(T0 &x0, T1 &x1, T2 &x2){OT(x0), OT(x1), OT(x2);}
template<class T0, class T1, class T2, class T3> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}

template<class T> inline void RST(T &A){memset(A, 0, sizeof(A));}
template<class T0, class T1> inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);}
template<class T0, class T1, class T2> inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);}
template<class T0, class T1, class T2, class T3> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}
template<class T> inline void CLR(T &A){A.clear();}
template<class T0, class T1> inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);}
template<class T0, class T1, class T2> inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);}
template<class T0, class T1, class T2, class T3> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);}
template<class T> inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);}
template<class T> inline void FLC(T &A, int x){memset(A, x, sizeof(A));}
template<class T0, class T1> inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}
template<class T0, class T1, class T2> inline void FLC(T0 &A0, T1 &A1, T2 &A2){FLC(A0), FLC(A1), FLC(A2);}
template<class T0, class T1, class T2, class T3> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3){FLC(A0), FLC(A1), FLC(A2), FLC(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5), FLC(A6);}

template<class T> inline void SRT(T &A){sort(ALL(A));}
template<class T, class C> inline void SRT(T &A, C B){sort(ALL(A), B);}

/** Add - On **/

const int MOD = 1000000007;
const int INF = 0x7fffffff;
const DB PI = acos(-1.0);
const DB EPS = 1e-6;
const DB OO = 1e15;

// <<= ` 0. Daily Use .,

template<class T> inline void checkMin(T &a,const T b){if (b<a) a=b;}
template<class T> inline void checkMax(T &a,const T b){if (b>a) a=b;}
template <class T, class C> inline void checkMin(T& a, const T b, C c){if (c(b,a)) a = b;}
template <class T, class C> inline void checkMax(T& a, const T b, C c){if (c(a,b)) a = b;}
template<class T> inline T min(T a, T b, T c){return min(min(a, b), c);}
template<class T> inline T max(T a, T b, T c){return max(max(a, b), c);}
template<class T> inline T sqr(T a){return a*a;}
template<class T> inline T cub(T a){return a*a*a;}
int Ceil(int x, int y){return (x - 1) / y + 1;}

// <<= ` 1. Bitwise Operation .,

inline bool _1(int x, int i){return x & 1<<i;}
inline int _1(int i){return 1<<i;}
inline int _U(int i){return _1(i) - 1;};

inline int count_bits(int x){
    x = (x & 0x55555555) + ((x & 0xaaaaaaaa) >> 1);
    x = (x & 0x33333333) + ((x & 0xcccccccc) >> 2);
    x = (x & 0x0f0f0f0f) + ((x & 0xf0f0f0f0) >> 4);
    x = (x & 0x00ff00ff) + ((x & 0xff00ff00) >> 8);
    x = (x & 0x0000ffff) + ((x & 0xffff0000) >> 16);
    return x;
}

template<class T> inline T low_bit(T x) {
    return x & -x;
}

template<class T> inline T high_bit(T x) {
    T p = low_bit(x);
    while (p != x) x -= p, p = low_bit(x);
    return p;
}

// <<= ` 2. Modular Arithmetic Basic .,

inline void INC(int &a, int b){a += b; if (a >= MOD) a -= MOD;}
inline int sum(int a, int b){a += b; if (a >= MOD) a -= MOD; return a;}
inline void DEC(int &a, int b){a -= b; if (a < 0) a += MOD;}
inline int dff(int a, int b){a -= b; if (a < 0) a  += MOD; return a;}
inline void MUL(int &a, int b){a = (LL)a * b % MOD;}
inline int pdt(int a, int b){return (LL)a * b % MOD;}

// <<= ' 0. I/O Accelerator interface .,

template<class T> inline void RD(T &x){
    //cin >> x;
    //scanf("%d", &x);
    char c; for (c = getchar(); c < '0'; c = getchar()); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';
    //char c; c = getchar(); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';

}

//int ____Case;
template<class T> inline void OT(const T &x){
    //cout << x << endl;
    //printf("%d\n", x);
    printf("%.12lf\n", x);
    //printf("Case %d: %d\n", ++____Case, x);
}

#define For_each(it, A) for (SII::iterator it = A.begin(); it != A.end(); ++it)

/* .................................................................................................................................. */

const int N = 1001;

VI A, B; LL pl, pr, vl, vr, k;
LL cnt;

void dfs(int k = 0, int n = 0){
    A.PB(n);
    if (k == 9) return;
    else{
        dfs(k+1, n * 10 + 4);
        dfs(k+1, n * 10 + 7);
    }
}

LL I(int l, int r, int l_, int r_){
    checkMax(l, l_), checkMin(r, r_);
    return max(0LL, LL(r - l + 1));
}

int main(){

    //freopen("in.txt", "r", stdin);

    dfs(), SRT(A), A.PB(INF);
    RD(pl, pr, vl, vr, k);

    REP_C(i, SZ(A) - k){
        int l1 = A[i-1] + 1, r1 = A[i], l2 = A[i + k - 1], r2 = A[i + k] - 1;
        LL d1 = I(l1, r1, pl, pr) * I(l2, r2, vl, vr), d2 = I(l1, r1, vl, vr) * I(l2, r2, pl, pr);
        cnt += d1 + d2; if (d2 && d2 && k == 1) --cnt;
    }

    OT( (DB) cnt /  ( (pr - pl + 1) * (vr - vl + 1)  ));
}

#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

const int max_n = 11, inf = 1000000000;

int pl, pr, vl, vr, k, L, R;
long long ans;
vector<int> v;

void gen(int x, int cnt) {
    v.push_back(x);
    if (cnt == 9) {
        return;
    }
    gen(x * 10 + 4, cnt + 1);
    gen(x * 10 + 7, cnt + 1);
}

int cnt(int l1, int r1, int l2, int r2) {
    if (l1 > l2) {
        swap(l1, l2);
        swap(r1, r2);
    }
    if (l2 > r1) {
        return 0;
    }
    return min(r1, r2) - l2 + 1;
}

void proc(int l1, int r1, int l2, int r2) {
    if (l1 > l2) {
        swap(l1, l2);
        swap(r1, r2);
    }
    if (l2 > r1) {
        return;
    }
    L = l2;
    R = min(r1, r2);
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> pl >> pr >> vl >> vr >> k;
    proc(pl, pr, vl, vr);
    gen(0, 0);
    v.push_back(inf + 10);
    sort(v.begin(), v.end());
    for (int i = 1; i + k < v.size(); ++i) {
        int l1 = v[i - 1] + 1;
        int r1 = v[i];
        int l2 = v[i + k - 1];
        int r2 = v[i + k] - 1;
        //if (i + k + 1 == v.size()) cout << i << ": " << v[i] << "  " << l1 << " " << r1 << "  " << l2 << " " << r2 << endl;
        long long c1 = cnt(l1, r1, pl, pr);
        long long c2 = cnt(l2, r2, vl, vr);
        ans += c1 * c2;
        c1 = cnt(l2, r2, pl, pr);
        c2 = cnt(l1, r1, vl, vr);
        ans += c1 * c2;
        if (k == 1 && L <= r1 && r1 <= R) ans -= 1;
    }
    printf("%.10f\n", 1.0 * ans / (pr - pl + 1) / (vr - vl + 1));
    return 0;
}

#include <bits/stdc++.h>

#define MAXN

int lt[10], num[2000], dp[2000], dv[2000], mp[2000], mv[2000];

int n;

void genLuckyNum() {
    num[0] = 0;
    n = 1;
    lt[0] = 1;
    for (int i = 1; i < 9; i++) lt[i] = lt[i-1] * 2;
    for (int i = 1; i <= 9; i++) {
        int en = (1 << i);
        for (int j = 0; j < en; j++) {
            int tmp = 0;
            for (int z = i-1; z >= 0; z--) {
                tmp = tmp*10 + ((j & lt[z])?7:4);
            }
            num[n++] = tmp;
        }
    }
    num[n] = 1000000001;
}

int min(int a, int b) {
    if (a < b) return a;
    return b;
}

int max(int a, int b) {
    if (a > b) return a;
    return b;
}

int main() {
    int pl, pr, vl, vr, k;
    scanf("%d%d%d%d%d", &pl, &pr, &vl, &vr, &k);
    genLuckyNum();
    //for (int i = n-1; i >= n-271; i--) printf("%d ", num[i]);
    int vtp = 1;
    long long res = 0;
    while (vtp < n && pl > num[vtp]) vtp++;
    int vtv = 1;
    while (vtv < n && vl > num[vtv]) vtv++;
    //printf("\nn = %d, vtp = %d, vtv = %d", n, vtp, vtv);
    //if (vtp < n && vtv < n)
    {
        // phan doan
        int pp, vv;
        pp = vtp;
        for (; pp <= n; pp++) {
            //printf("\nnum pp = %d, %d, %d", pp, num[pp], num[pp-1]);
            if (num[pp-1] >= pr) break;
            int tmp1 = min(num[pp], pr) - max(num[pp-1]+1, pl) + 1;
            //printf("\ntmp1 = %d, left = %d, right = %d", tmp1, max(num[pp-1]+1, pl), min(num[pp], pr));
            if (pp+k-1 >= n || num[pp+k-1] > vr) break;
            int tmp2 = min(num[pp+k]-1, vr) - max(num[pp+k-1], vl) + 1;
            //printf("\ntmp2 = %d, left = %d, right = %d", tmp2, max(num[pp+k-1], vl), min(num[pp+k]-1, vr));
            if (num[pp+k] > vl) res += (long long)tmp1 * tmp2;
        }
        //printf("\n%I64d\n", res);
        vv = vtv;
        for (; vv <= n; vv++) {
            if (num[vv-1] >= vr) break;
            int tmp1 = min(num[vv], vr) - max(num[vv-1]+1, vl) + 1;
            //printf("\ntmp1 = %d, left = %d, right = %d", tmp1, max(num[vv-1]+1, vl), min(num[vv], vr));
            if (vv+k-1 >= n || num[vv+k-1] > pr) break;
            int tmp2 = min(num[vv+k]-1, pr) - max(num[vv+k-1], pl) + 1;
            //printf("\ntmp1 = %d, left = %d, right = %d", tmp1, max(num[vv-1]+1, vl), min(num[vv], vr));
            if (num[vv+k] > pl) res += (long long)tmp1 * tmp2;
        }
        if (k == 1) {
            for (int i = vtp; i < n; i++) {
                if (num[i] <= pr && num[i] >= vl && num[i] <= vr) res--;
            }
        }
    }

    double total = 1.0;
    total *= (pr-pl+1);
    total *= (vr-vl+1);
    //printf("\n%I64d\n", res);
    printf("%.15lf", (res/total));

    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector <long long> v;
void gen(int n,long long w)
{
	int k=0;
	long long a=w;
	while (a)
	{
		a/=10;
		k++;
	}
	if (k==n) v.push_back(w);
	else
	{
		gen(n,w*10+4);
		gen(n,w*10+7);
	}
}
long long per(long long l1,long long r1,long long l2,long long r2)
{
	if (r1<l2||r2<l1) return 0;
	else
	{
		if (l1<=l2)
		{
			if (r1>=r2) return r2-l2+1;
			else return r1-l2+1;
		}
		else
		{
			if (r2>=r1) return r1-l1+1;
			else return r2-l1+1;
		}
	}
}
int main()
{
	int k;
	long long pl,pr,vl,vr;
	cin >> pl >> pr >> vl >> vr >> k;
	for (int i=1;i<10;i++) gen(i,0);
	v.push_back(0);
	v.push_back(1000000001);
	sort(v.begin(),v.end());
	long long s=0;
	for (int i=1;i<v.size()-k;i++)
	{
		int j=i+k-1;
		s+=per(v[i-1]+1,v[i],pl,pr)*per(v[j],v[j+1]-1,vl,vr);
		s+=per(v[i-1]+1,v[i],vl,vr)*per(v[j],v[j+1]-1,pl,pr);
		if (k==1) s-=per(v[i],v[i],pl,pr)*per(v[j],v[j],vl,vr);
	}
	cout.precision(15);
	cout << double(s)/((pr-pl+1)*(vr-vl+1)) << endl;
	return 0;
}

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

vector<ll> num;
int n;
ll pl, pr, vl, vr, k;
ll ans = 0;

void dfs(ll x) {
	if(x >= 1e9) return;
	num.push_back(x);
	dfs(x*10+4);
	dfs(x*10+7);
}

inline ll calc(ll l, ll r, ll x, ll y) {
	if(r < x || l > y) return 0;
	if(l>r || x>y) return 0;
	if(l >= x && l <= y) return min(r, y)-l+1;
	if(r >= x && r <= y) return r-max(l, x)+1;
	if(l < x && r > y) return y-x+1;
}

int main() {
	dfs(0);
	n = num.size();
	num.push_back(1e16);
	sort(num.begin(), num.end());
	cin >> pl >> pr >> vl >> vr >> k;
	for(int i = 1; i+k-1 <= n; i++) {
		if(num[i] > vr && num[i]>pr) break;
		int j = i+k-1;
		ans += calc(num[i-1]+1, num[i], pl, pr)*calc(num[j], num[j+1]-1, vl, vr);
		ans += calc(num[j], num[j+1]-1, pl, pr)*calc(num[i-1]+1, num[i], vl, vr);
		if(k == 1) {
			if(calc(pl, pr, num[i], num[i]) && calc(vl, vr, num[i], num[i]))
				ans--;
		}
	}
	printf("%.12lf", ans*1.0/(vr-vl+1)/(pr-pl+1), 1.0);

	return 0;
}

#include <stdio.h>
#include <math.h>
#include <iostream>
#include <sstream>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#include <queue>
#include <string>

using namespace std;
int a[20000];
int n,i,j,k,l1,l2,r1,r2;
double ans;
__int64 x;

__int64 inter(int l1,int r1,int l2,int r2)
{
	if(r1<l2 || r2<l1)
		return 0;
	int l,r;
	l=l1<l2?l2:l1;
	r=r1>r2?r2:r1;
	return r-l+1;
}

int main()
{
	for(i=1;i<10;i++)
		for(j=0;j<(1<<i);j++)
		{
			a[n]=0;
			for(k=0;k<i;k++)
				if(j&(1<<k))
					a[n]=a[n]*10+7;
				else
					a[n]=a[n]*10+4;
			n++;
		}
	a[n++]=0;
	a[n++]=1000000001;
	sort(a,a+n);
	scanf("%d%d%d%d%d",&l1,&r1,&l2,&r2,&k);
	for(i=1;i+k<n;i++)
	{
		x+=inter(l1,r1,a[i-1]+1,a[i])*inter(l2,r2,a[i+k-1],a[i+k]-1);
		x+=inter(l2,r2,a[i-1]+1,a[i])*inter(l1,r1,a[i+k-1],a[i+k]-1);
		if(k==1 && a[i]>=l1 && a[i]<=r1 && a[i]>=l2 && a[i]<=r2)
			x--;
	}
	printf("%.15lf\n",1.0*x/(r1-l1+1)/(r2-l2+1));
	return 0;
}

#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <utility>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
#define two(X) (1<<(X))
#define twoL(X) (((int64)(1))<<(X))
#define contain(S,X) ((S&two(X))>0)
#define containL(S,X) ((S&twoL(X))>0)
typedef pair<int,int> PIIS;
int countbit(int n) {return (n==0)?0:(1+countbit(n&(n-1)));}
int lowbit(int n) {return (n^(n-1))&n;}
const double pi=acos(-1.0);
const double eps=1e-11;
template<class T> T sqr(T x) {return x*x;}
template<class T> void checkmin(T &a,T b) {if (b<a) a=b;}
template<class T> void checkmax(T &a,T b) {if (b>a) a=b;}
#define SIZE(X) ((int)((X).size()))
#define LENGTH(X) ((int)((X).length()))
#define MP(A,B) make_pair(A,B)

set<int> lucky;
vector<int> L;

void init( LL n )
{
	if( n )
		lucky.insert( n );
	if( n < 100000000 )
	{
		init( n * 10 + 4 );
		init( n * 10 + 7 );
	}
}

int main()
{
#if	_MSC_VER == 1500
	freopen( "in.txt", "r", stdin );
#endif
	// code here
	int pl, pr, vl, vr, k;
	cin >> pl >> pr >> vl >> vr >> k;
	init( 0 );
	L.assign( lucky.begin(), lucky.end() );
	int len = L.size();
	double ans = 0;
	for( int i = 0; i + k <= len; ++ i )
	{
		int left = L[i], exleft = i == 0 ? -2 : L[i - 1];
		int right = L[i + k - 1], exright = i + k == len ? 1000000002 : L[i + k];
		int lenp = pr - pl + 1, lenv = vr - vl  + 1;
		int l1 = max( exleft + 1, pl ), l2 = min( left, pr );
		int r1 = max( right, vl ), r2 = min( exright - 1, vr );
		int flag = 0;
		if( l2 == left ) flag = 1;
		if( pl <= left && pr > exleft && vr >= right && vl < exright )
			ans += double( l2 - l1 + 1 ) / lenp * ( r2 - r1 + 1 ) / lenv;
		if( vl <= left && vr > exleft && pr >= right && pl < exright )
		{
			l1 = max( exleft + 1, vl ), l2 = min( left, vr );
			r1 = max( right, pl ), r2 = min( exright - 1, pr );
			if( l2 == left ) flag += 2;
			ans += double( l2 - l1 + 1 ) / lenp * ( r2 - r1 + 1 ) / lenv;
			if( k == 1 && flag == 3 )
				ans -= 1.00 / lenp / lenv;
		}

	}
	printf( "%.10lf\n", ans );
	return 0;
}

#include <cctype>
#include <iostream>
#include <fstream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <iomanip>
#include <iterator>
#define forn(i , n) for (int i = 0; i < n; ++i)
#define down(i, n) for (int i = n - 1; i >= 0; --i)
#define inf 1000000007
#define eps = 0.0000000001
using namespace std;
typedef unsigned long long u64;
typedef long long i64;
typedef vector<int> vint;
typedef vector<u64> vu64;
typedef vector<vector<int>> graph;    // +h-wl7xi // izh_camp04
typedef pair<int, int> pint;
typedef pair<i64, i64> pi64;
typedef int huint;

ifstream in("buffcraft.in", ios::in);
ofstream out("buffcraft.out", ios::out);

int pl,pr,vl,vr,k;
vint p;
void dfs(long long x) {
    if (x < 1000000000) {
        p.push_back(x);
        dfs(x*10+4);
        dfs(x*10+7);
    }
}

int main()
{
    dfs(0);
    p.push_back(INT_MAX);
   // cout << p.size();
    sort(p.begin(),p.end());
    cin >> pl >> pr >> vl >> vr >> k;
    double cnt=0;
    double all=((vr-vl)+1.0)*((pr-pl)+1.0);

    for (int i = 1; i < p.size()-k; i++)
    {
        int lm=p[i-1]+1,l=p[i],r=p[i+k-1],rp=p[i+k]-1;
        if (pl<=l && pr>=lm && vl<=rp && vr>=r)
            cnt += ( min(pr, l ) - max(pl, lm) + 1.0) * ( min(vr, rp) - max(vl,r) + 1.0);

        if (vl<=l && vr>=lm && pl<=rp && pr>=r)
        {
            cnt += ( min(vr,l) - max(vl, lm) + 1.0) * ( min(pr, rp) - max(pl, r) + 1.0);
            if (k == 1)
                cnt -= 1.0;
        }
    }
    cout << setprecision(10) << cnt/all;
}

#pragma comment(linker, "/STACK:128777216")
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <intrin.h>
using namespace std;

#define For(i, n) for (int i = 0; i < (n); ++i)
#define sz(v) (int)(v).size()
#define forx(_name,_from, to, value) for (int name = from; name < to; name += value)
#define rforx(_name, from, to, value) for (int name = from; name > to; name -= _value)
#define all(_STL_NAME) _STL_NAME.begin(), _STL_NAME.end()
#define rall(_STL_NAME) _STL_NAME.rbegin(), _STL_NAME.rend()
#define mp(_FIRST,_SECOND) make_pair(_FIRST,_SECOND)

typedef long long ll;
typedef long long lint;
typedef unsigned long long llu;
typedef long double ld;
const ld eps = 1e-9;
mt19937 rndm;

void start() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cout.precision(6); cout.setf(ios::fixed);
	rndm.seed((unsigned int)time(0));
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

const int MAX_N = (int)1e6 + 10;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9 + 7;

pair <int, int> FindIntersection(int l1, int r1, int l2, int r2) {
	int l = max(l1, l2);
	int r = min(r1, r2);
	if (r < l)
		return { -1, -1 };
	return { l, r };
}

void solve() {
	int p_l, p_r, v_l, v_r, k;
	scanf("%d %d %d %d %d", &p_l, &p_r, &v_l, &v_r, &k);
	vector <int> numbers;
	for (int dig = 1; dig <= 9; dig++) {
		for (int i = 0; i < (1 << dig); i++) {
			int x = 0;
			for (int j = 0; j < dig; j++) {
				if (i & (1 << j))
					x = 10 * x + 7;
				else
					x = 10 * x + 4;
			}
			numbers.push_back(x);
		}
	}
	sort(numbers.begin(), numbers.end());
	int n = numbers.size();
	ll cnt = 0;
	for (int i = 0; i < n - k + 1; i++) {
		int has_one = 0;
		pair <int, int> p1 = FindIntersection(p_l, p_r, i != 0 ? numbers[i - 1] + 1 : 0, numbers[i]);
		pair <int, int> p2 = FindIntersection(v_l, v_r, numbers[i + k - 1], i + k != n ? numbers[i + k] - 1 : INF);
		if (p1.first != -1 && p2.first != -1) {
			cnt += ((ll)p1.second - p1.first + 1) * ((ll)p2.second - p2.first + 1);
			has_one += p1.second == p2.first;
		}
		p1 = FindIntersection(v_l, v_r, i != 0 ? numbers[i - 1] + 1 : 0, numbers[i]);
		p2 = FindIntersection(p_l, p_r, numbers[i + k - 1], i + k != n ? numbers[i + k] - 1 : INF);
		if (p1.first != -1 && p2.first != -1) {
			cnt += ((ll)p1.second - p1.first + 1) * ((ll)p2.second - p2.first + 1);
			has_one += p1.second == p2.first;
		}
		if (has_one == 2)
			cnt--;
	}
	double ans = ((double)cnt) / (((double)p_r - p_l + 1) * ((double)v_r - v_l + 1));
	printf("%.9lf", ans);
}

void multitest() {
	int t;
	scanf("%d", &t);
	for (int i = 1; i <= t; i++) {
		solve();
	}
}

int main() {
	start();
	solve();
	//multitest();
#ifdef _DEBUG
	cout << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}

#include "iostream"
#include "cstdio"
#include "algorithm"
#include "string"
#include "vector"
#include "cstdlib"
#include "cmath"
#include "map"
#include "queue"
#include "set"
#include "cstring"
#include "complex"

using namespace std;

#define clr(a,b) memset(a, b, sizeof(a))
#define cpy(a, b) memcpy(a, b, sizeof(b))
#define sz(a) ((int)a.size())

typedef long long ll;
typedef pair<int, int> pi;
typedef complex<double> point;

const double eps=1e-6;
const int inf = (int)1e9;
const int MAX_N = 1000 + 10;
const int REM = inf + 7;

set <ll> S;
vector <int> v;

void rec(int depth, ll here){
	if(here > inf) return;
	if(depth) S.insert(here);
	rec(depth + 1, here * 10 + 4);
	rec(depth + 1, here * 10 + 7);
}

int common_part(pi x, pi y){
	if(x.first > y.first) swap(x, y);
	if(y.first > x.second) return 0;
	return min(x.second, y.second) - y.first + 1;
}

int main(){
	//freopen("in.in", "r", stdin);
	int a, b, c, d, k;
	cin >> a >> b >> c >> d >> k;
	rec(0, 0);
	v.assign(S.begin(), S.end());
	double div = (b-a+1.)*(d-c+1.), ret = 0;
	for(int i = 0; i < sz(v); i++){
		if(i + k > sz(v)) break;
		int prev = (i ? v[i - 1] : -inf);
		int next = (i + k < sz(v) ? v[i + k] : inf + 1000);
		int lef = v[i], righ = v[i + k - 1];
		double p, r;
		p = common_part(pi(prev + 1, lef), pi(a, b));
		r = common_part(pi(righ, next - 1), pi(c, d));
		ret += (p*r)/div;
		p = common_part(pi(prev + 1, lef), pi(c, d));
		r = common_part(pi(righ, next - 1), pi(a, b));
		ret += (p*r)/div;
		if(k == 1 && lef >= a && lef <= b && lef >= c && lef <= d)
			ret -= 1 / div;
	}
	printf("%.10f\n", ret);
	return 0;
}

#include<stdio.h>
#include<iostream>
#include<algorithm>
typedef long long LL;
using namespace std;
LL a[111111],l,r,L,R,k,x,y,z;
int c=0;
using namespace std;
void dfs(LL x){
    if(x>1e10)return;
    a[c++]=x;
    dfs(x*10+4);
    dfs(x*10+7);
}
LL ct(LL l,LL r,LL L,LL R){
    return max(min(r,R)-max(l,L)+1,0LL);
}
int main(){
    dfs(0);
    sort(a,a+c);
    cin>>l>>r>>L>>R>>k;
    for(int i=1,j;i+k<c;i++){
        j=i+k;
        x=ct(a[i-1]+1,a[i],l,r);
        y=ct(a[j-1],a[j]-1,L,R);
        z+=x*y;
        x=ct(a[i-1]+1,a[i],L,R);
        y=ct(a[j-1],a[j]-1,l,r);
        z+=x*y;
        if(k==1)z-=ct(l,r,a[i],a[i])*ct(L,R,a[i],a[i]);
    }
    printf("%.15lf",1.*z/(r-l+1)/(R-L+1));
    return 0;
}

#include <iostream>
#include <fstream>
#include <string>
#include <set>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;
typedef unsigned long long ll;
int tens[] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000};
vector<int> nums;
void getc(int b, int start)
{
	int c = 0;
	int ret = 0;
	int t = b;
	while(t)
	{
		t/=10;
		c++;
	}

	int base = 0;
	int curr = 0;
	if(c == 10)
		--c;
	for(int digCount = 1; digCount <= c; ++digCount)
	{
		base = 0;
		for(int k = 0 ; k < digCount; ++k)
			base += 4*tens[k];
		for(int i = 0 ; i < 1<<(digCount); ++i)
		{
			curr = base;
			for(int j = 0; j < digCount; ++j)
			{
				if(1<<j&i)
					curr+=tens[j]*3;
			}
			if(curr <= b)
			{
				if(curr >= start)
					nums.push_back(curr);
			}
			else
				return;
		}
	}
	return;
}

ll inter(ll l1, ll r1, ll l2, ll r2)
{
	ll l = l1 > l2 ? l1 : l2;
	ll r = r1 < r2 ? r1 : r2;

	return r >= l > 0 ? r-l+1 : 0;
}

int main() {
#ifdef _DEBUG
	freopen("t.in", "r", stdin);
	freopen("t.out", "w", stdout);
#endif
	int vl,vr,pl,pr,k,r,l;
	scanf("%d%d%d%d%d", &vl,&vr,&pl,&pr,&k);
	r = max(vr,pr);
	l = min(vl,pl);

	getc(r, l);
	unsigned long long omega = (ll)(vr-vl+1)*(pr-pl+1);

	if(nums.size() < k)
	{
		puts("0");
		return 0;
	}
	unsigned long long c = 0;
	k--;
	ll l1, l2, r1, r2;
	for(int i = 0 ; i + k < nums.size(); ++i)
	{
		l1 = i > 0 ? nums[i-1] + 1 : 0;
		r1 = nums[i];

		l2 = nums[i+k];
		r2 = i+k+1 < nums.size() ? nums[i + k + 1] -1 : 1000000001;

		c += inter(l1,r1,vl,vr)*inter(l2,r2,pl,pr);
		c += inter(l1,r1,pl,pr)*inter(l2,r2,vl,vr);
		if(k == 0 && (vl <= r1 && vr >= r1) && (pl <= r1 && pr >= r1))
			c--;
	}

	printf("%.12lf\n", (double)c/omega);

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
const int INF = numeric_limits<int>::max();
const double EPS = 1e-10;
const l e5 = 100000, e6 = 1000000, e7 = 10000000, e9 = 1000000000;

// #define ONLINE_JUDGE
#if defined ONLINE_JUDGE
const bool enable_log = false;
#else
const bool enable_log = true;
#endif
struct VoidStream { void operator&(std::ostream&) { } };
#define LOG !(enable_log) ? (void) 0 : VoidStream() & cerr

l intersect(l a, l b, l c, l d) {
  return max((l)0, min(b,d) - max(a,c) + 1);
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  vl lucky = {0, 4, 7};
  {
    l from = 1;
    for (l i = 0; i < 9; i++) {
      l n = lucky.size();
      for (l j = from; j < n; j++) {
        lucky.emplace_back(lucky[j] * 10 + 4);
        lucky.emplace_back(lucky[j] * 10 + 7);
      }
      from = n;
    }
  }
  l pl, pr, ul, ur, k;
  while (cin >> pl >> pr >> ul >> ur >> k) {
    auto a = lucky.begin();
    auto b = ((k + 1) < lucky.size()) ? (lucky.begin() + k + 1) : lucky.end();
    l total = 0;
    while (b != lucky.end()) {
      l al = *a + 1, ar = *(a + 1), bl = *(b - 1), br = *b - 1;
      l d = intersect(al, ar, pl, pr) * intersect(bl, br, ul, ur) +
        intersect(al, ar, ul, ur) * intersect(bl, br, pl, pr);
      if (k == 1 and intersect(pl, pr, ar, ar) and intersect(ul, ur, ar, ar)) d--;
      total += d;
      a++;
      b++;
    }
    // LOG << "total" << total << endl;
    cout.precision(12);
    cout << fixed
         << ((double)total) / ((double)((pr - pl + 1) * (ur - ul + 1)))
         << '\n';
  }
}

// esta3anna 3al sha2a belAllah ..
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<sstream>
#include<limits.h>
#include<iomanip>
#include<cstring>
#include<bitset>
#include<fstream>
#include<cmath>
#include<cassert>
#include <stdio.h>
#include<ctype.h>
using namespace std;
#define rep(i,n,m) for(int i = (int)(n), _m = (int)(m); i < _m; ++ i)
#define	rrep(i,n,m) for(int i = (int)(n), _m = (int)(m); i >= _m; -- i)
#define foreach(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz size()
#define pb push_back
#define mp make_pair
#define mems(arr, v) memset(arr, v, sizeof arr)
#define setBit(mask, bit) ((mask) | (1LL << (bit)))
#define resetBit(mask, bit) ((mask) & (~(1LL << (bit))))
#define flipBit(mask, bit) ((mask) ^ (1LL << (bit)))
#define is0(mask, bit)(((mask) & (1LL << (bit))) == 0)
#define is1(mask, bit)(((mask) & (1LL << (bit))) != 0)
#define removeLastBit(mask) ((mask) & ((mask) - 1LL))
#define firstBitOn(mask) ((mask) & ~((mask) - 1LL))
#define grayCode(mask) ((mask) ^ ((mask) << 1LL))
#define repSubMasks(subMask, mask) for(ll subMask = (ll)(mask), _mask = subMask; subMask; subMask = _mask & (subMask - 1))
int countBits(int mask) {int res = 0; while(mask) mask &= (mask - 1), ++ res; return res;}
string toString(long long n) {stringstream ss; ss << n; return ss.str();}
long long toNumber(string s) {stringstream ss; long long n; ss << s; ss >> n; return n;}
#define INT_MAX  2000000000
#define INT_MIN -INT_MAX
#define EPS 1e-9
#define debug(x) cout << #x << " : " << x << endl
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define Read() freopen("input.txt","r",stdin)
#define Write() freopen("output.txt","w",stdout)
vector<int> all;
void generate(ll curr) {
	if(curr > 1e9)
		return;
	all.pb(curr);
	generate(curr * 10 + 4);
	generate(curr * 10 + 7);
}
ld getCommon(ld a, ld b, ld i, ld j) {
	if(a < i && b < i)
		return 0;
	if(a > j && b > j)
		return 0;
	int start = max(a, i);
	int end = min(b, j);
	return end - start + 1;
}
int main() {
//	Read();
	int p1, p2, v1, v2, k;
	ld res = 0;
	generate(4), generate(7);
	sort(all(all));
	cin >> p1 >> p2 >> v1 >> v2 >> k;
	rep(start, 0, all.size()) {
		int end = start + k - 1;
		if(end >= all.size())
			break;
		ld pre = start == 0 ? 0: all[start - 1] + 1;
		ld post = end == all.size() - 1 ? 1e9: all[end + 1] - 1;
		ld a = getCommon(p1, p2, pre, all[start]);
		ld b = getCommon(v1, v2, all[end], post);
		res += a * b;
		a = getCommon(v1, v2, pre, all[start]);
		b = getCommon(p1, p2, all[end], post);
		if(k == 1 && p1 == v1 && p2 == v1);
		else
			res += a * b;
	}
	printf("%.12f\n", res / (p2 - p1 + 1) / (v2 - v1 + 1));
}

/*
  ------------------------- Hachiikung ---------------------------------
  ---------------------- Worrachate Bosri ------------------------------
  ------ Faculty of Computer Engineering Chulalongkorn University ------
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<map>
#include<string>
#include<utility>
using namespace std;
#define REP(i,FN) for(int i=0;i<FN;i++)
#define FOR(i,ST,FN) for(int i=ST;i<=FN;i++)
#define FORD(i,FN,ST) for(int i=FN;i>=ST;i--)
#define FORX(i,c) for(typeof(c.begin())i=c.begin();i!=c.end();i++)
#define pause system("pause")
#define S scanf
#define P printf
#define X first
#define Y second
#define pb push_back
#define PII pair<int,int>
#define mp make_pair
#define sz size()
#define eps 1e-8

const int MOD(1000000007);
const int INF((1<<30)-1);
const int MAXN();

long long intersect(long long x1,long long y1,long long x2,long long y2){
    return max(0ll, min(y1,y2)-max(x1,x2)+1);
}

int main(){

    vector<long long>a;

    a.pb(4);
    a.pb(7);

    REP(i,a.sz)
    {
        if(a[i]*10+4 <= 1e9)
            a.pb(a[i]*10+4);
        if(a[i]*10+7 <= 1e9)
            a.pb(a[i]*10+7);
    }

    int k;
    long long x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2 >> k;

    long long ans = 0, l, r;

    FOR(i,k-1,a.sz-1)
    {
        if(i-k >= 0) l = a[i-k]+1;
        else l = 1;

        if(k+1 < a.sz) r = a[i+1]-1;
        else r = 1e9;

        ans += intersect(l,a[i-k+1],x1,y1) * intersect(a[i],r,x2,y2);
        ans += intersect(l,a[i-k+1],x2,y2) * intersect(a[i],r,x1,y1);

        if(k == 1)
            ans -= intersect(a[i],a[i],x1,y1) * intersect(a[i],a[i],x2,y2);
    }

    P("%.10lf",ans*1.0/((y1-x1+1)*(y2-x2+1)));

}

# include <iostream>
# include <cmath>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <cctype>
# include <ctime>
# include <string>
# include <vector>
# include <queue>
# include <stack>
# include <functional>
# include <numeric>
# include <algorithm>
# include <list>
# include <map>
# include <set>
# include <iterator>
# include <utility>
# include <sstream>
# include <fstream>
# include <iomanip>
# include <exception>
# define FOR(i, n, m) for (i = (n); i < (m); i++)
# define FORR(i, n, m) for (i = (n); i >= (m); i--)
# define LLI long long int
# define ULL unsigned long long
# define PII pair < int, int >
# define MP make_pair
# define VI vector < int >
# define VS vector < string >
# define SS stringstream
# define FS first
# define SN second
# define PB push_back
# define BE begin
# define EN end
# define CL(v, val) memset(v, val, sizeof v)
# define ALL(v) v.begin(), v.end()
# define INF 0x3f3f3f3f
# define ISDIG(c) (c >= '0' && c <= '9')
using namespace std;

VI posibles(int a, int b)
{
    int i, j, n, m, c, v[2] = {4, 7};
    VI res;

    FOR (n, 1, 10) {
        m = 1 << n;
        FOR (i, 0, m) {
            c = 0;
            FOR (j, 0, n) {
                c = c * 10 + v[(i & (1 << j)) >> j];
            }

            if (a <= c && c <= b) {
                res.PB(c);
            }
        }
    }

    sort(res.begin(), res.end());

    return res;
}

int read()
{
    int n;
    char c;
    bool neg;

    n = 0;
    neg = false;

    for (c = getchar(); !ISDIG(c) && c != '-'; c = getchar());

    if (c == '-') {
        neg = true;
        c = getchar();
    }

    while(ISDIG(c)) {
        n = n * 10 + c - '0';
        c = getchar();
    }

    return neg ? -n : n;
}

int interseccion(int x1, int y1, int x2, int y2)
{
    if ((x2 <= x1 && x1 <= y2) || (x2 <= y1 && y1 <= y2)) {
        return min(y1, y2) - max(x1, x2) + 1;
    }

    if ((x1 <= x2 && x2 <= y1) || (x1 <= y2 && y2 <= y1)) {
        return min(y1, y2) - max(x1, x2) + 1;
    }

    return 0;
}

int main()
{
    int pl, pr, vl, vr, k, i, j, t1, t2, x1, y1, x2, y2;
    double res, nm;
    VI v;

    cin >> pl >> pr >> vl >> vr >> k;
    nm = double((LLI) (pr - pl + 1) * (LLI) (vr - vl + 1));
    v = posibles(min(pl, vl), max(pr, vr));

    res = 0.0;
    if ((int) v.size() >= k) {
        for (i = 0, j = k - 1; j < (int) v.size(); i++, j++) {
            if (i == 0) {
                x1 = 1;
            }
            else {
                x1 = v[i - 1];
            }
            y1 = v[i];

            x2 = v[j];
            if (j + 1 == (int) v.size()) {
                y2 = 1000000000;
            }
            else {
                y2 = v[j + 1];
            }

            t1 = interseccion(x1, y1, vl, vr);
            t2 = interseccion(x2, y2, pl, pr);
            res += double((LLI) t1 * (LLI) t2) / nm;

            t1 = interseccion(x1, y1, pl, pr);
            t2 = interseccion(x2, y2, vl, vr);
            res += double((LLI) t1 * (LLI) t2) / nm;
        }
    }

    cout << res << endl;

    return 0;
}

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

#define LL long long
#define NL '\n'
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%I64d",&x)
#define sd(x) scanf("%lf",&x)
#define ss(x) scanf("%s",x)
#define mem(a,b) memset(a,b,sizeof(a))
#define FOR(i,j,k) for(i=j;i<=k;i++)
#define REV(i,j,k) for(i=j;i>=k;i--)
#define READ(f) freopen(f,"r",stdin)
#define WRITE(f) freopen(f,"w",stdout)
#define cnd tree[idx]
#define lnd tree[idx*2]
#define rnd tree[(idx*2)+1]
#define lndp (idx*2),(b),((b+e)/2)
#define rndp (idx*2+1),((b+e)/2+1),(e)
#define pi 2.0*acos(0.0)
#define MOD 1000000007
#define MAX 10000

int sz, lucky[MAX];

void go(LL n)
{
    if(n > MOD) return ;
    lucky[sz++] = n;
    go(n*10 + 4);
    go(n*10 + 7);
}

int main()
{
    //READ("input.txt");
    //WRITE("out.txt");
    std::ios_base::sync_with_stdio(0);
    int cases, caseno=0, n, i, j, k, pl, bl, br, pr, x, y;

    cin >> pl >> pr >> bl >> br >> k;

    sz = 0;
    go(4);
    go(7);

    sort(lucky,lucky+sz);

    double p_total = pr - pl + 1;
    double b_total = br - bl + 1;
    double sum = 0.0, low, high, cnt=0;

    FOR(i,k-1,sz-1)
    {
        if(pl <= lucky[i-k+1] && br >= lucky[i])
        {
            if(i >= k) low = max(0, min(pr,lucky[i-k+1])-max(pl,lucky[i-k]+1)+1);
            else low = max(0, min(pr,lucky[i-k+1])-pl+1);

            if(i < sz-1) high = max(0, min(br,lucky[i+1]-1)-max(bl,lucky[i])+1);
            else high = max(0, br-max(bl,lucky[i])+1);

            sum += ((low/p_total) * (high/b_total));
        }
        if(bl <= lucky[i-k+1] && pr >= lucky[i] && !(bl == pl && br == br && br == bl))
        {
            if(i >= k) low = max(0, min(br,lucky[i-k+1])-max(bl,lucky[i-k]+1)+1);
            else low = max(0, min(br,lucky[i-k+1])-bl+1);

            if(i < sz-1) high = max(0, min(pr,lucky[i+1]-1)-max(pl,lucky[i])+1);
            else high = max(0, pr-max(pl,lucky[i])+1);

            sum +=  ((low/b_total) * (high/p_total));
        }
    }

    cout << fixed;
    cout << setprecision(12) << sum << NL;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define limite 1000000000LL
typedef long long int LL;
vector<LL> v;
void dfs(LL n) {
    v.push_back(n);
    if( n * 10LL + 4LL < limite ) dfs(n * 10LL + 4LL);
    if( n * 10LL + 7LL < limite ) dfs(n * 10LL + 7LL);
}
LL f(pair<LL, LL> rango, LL a, LL b) {
    if( rango.second < a || b < rango.first ) return 0LL;
    if( rango.first <= a && b <= rango.second ) return b - a + 1LL;
    if( a <= rango.first && rango.second <= b ) return rango.second - rango.first + 1LL;
    if( rango.first >= a ) return b - rango.first + 1LL;
    return rango.second - a + 1LL;
}
int main() {
    dfs(4); dfs(7);
    v.push_back(0);
    v.push_back(limite + 1);
    sort(v.begin(), v.end());
    pair<LL, LL> a, b;
    LL cnt, sum = 0LL;
    cin>>a.first>>a.second>>b.first>>b.second>>cnt;
    for(int i=0 ; i+cnt<v.size() ; i++) {
        if( i == 0 || i == v.size() - 1 ) continue;
        LL tmpA = f(a, v[i - 1] + 1LL, v[i]);
        LL tmpB = f(b, v[i + cnt - 1], v[i + cnt] - 1LL);
        sum += tmpA * tmpB;
        tmpA = f(b, v[i - 1] + 1LL, v[i]);
        tmpB = f(a, v[i + cnt - 1], v[i + cnt] - 1LL);
        sum += tmpA * tmpB;
    }
    LL lenA = a.second - a.first + 1LL;
    LL lenB = b.second - b.first + 1LL;
    printf("%.12lf\n", (double)sum / (lenA * lenB) );
    return 0;
}

#include <cstdio>
#include <vector>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
vector<int> lucky;
void func0(int x)
{
	if (x > 0) lucky.push_back(x);
	for (int i=4; i<8; i+=3)
		if (10LL*x+i < 1000000000) func0(10*x+i);
}

int func(int l, int r, int a, int b)
{
	if (l <= a && b <= r) return b - a + 1;
	if (l <= a) return max(0, r - a + 1);
	if (b <= r) return max(0, b - l + 1);
	return r - l + 1;
}

int main()
{
	func0(0);
	lucky.push_back(0);
	lucky.push_back(2000000000);
	sort(lucky.begin(), lucky.end());
	int pl, pr, vl, vr, k;
	while (~scanf("%d%d%d%d%d", &pl, &pr, &vl, &vr, &k)) {
		double a = (pr - pl + 1.) * (vr - vl + 1.);
		double res = 0;
		REP(i, 1, lucky.size()-k) {
			int p0 = func(pl, pr, lucky[i-1]+1, lucky[i]);
			int v0 = func(vl, vr, lucky[i-1]+1, lucky[i]);
			int p1 = func(pl, pr, lucky[i+k-1], lucky[i+k]-1);
			int v1 = func(vl, vr, lucky[i+k-1], lucky[i+k]-1);
			res += (p0 * v1 + p1 * v0);
		}
		printf("%.10f\n", res / a);
	}
	return 0;
}

#include<iostream>
#include<set>
#include<map>
#include<functional>
#include<queue>
#include<string.h>
#include<stdio.h>
#include<iomanip>
#include<stdlib.h>
#include<math.h>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<bitset>
#include<fstream>
typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define sz(a) (int)a.size()
#define sqr(x) ((x) * (x))
#define pi pair<ll, ll>
#define mk(a, b) make_pair(a, b)
#define nextI nextInt()
#define nextD nextDouble()
#define nextL nextLong()
#define nextC nextChar()
#define line newLine()
int nextInt(){ int x; scanf("%d", &x); return x; }
double nextDouble(){ double x; scanf("%lf", &x); return x; }
ll nextLong(){ ll x; scanf("%I64d", &x); return x; }
char nextChar(){ char x; scanf("%c", &x); return x; }
void newLine(){ printf("\n"); }
int gcd(int a, int b){ return b == 0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b){ return (a*b) / gcd(a, b); }
ll powM(ll a, ll b, ll MOD){ ll x = 1, y = a; while (b > 0){ if (b % 2 == 1){ x = (x*y); if (x>MOD) x %= MOD; }y = (y*y); if (y>MOD) y %= MOD; b /= 2; }return x; }
int countBitSet(ll n){ int ans = 0;  while (n != 0){ n -= (n & -n); ++ans; } return ans; }
ll mod = ll(1e9 + 7);
ll mod2 = 1e9 + 9;
const int N = 100100;
const int M = 100;
const double eps = (double)1e-6;
using namespace std;

vector<ll> v;
void bfs(){
	queue<ll> q;
	q.push(4);
	q.push(7);
	while (!q.empty()){
		ll x = q.front();
		q.pop();
		v.push_back(x);
		ll v1 = x * 10 + 4;
		ll v2 = x * 10 + 7;
		if (v1 < 1e9) q.push(v1);
		if (v2 < 1e9) q.push(v2);
	}
}

ll intersect(ll x1, ll y11, ll x2, ll y2){
	ll mx = max(x1, x2);
	ll mn = min(y11, y2);
	if (mn < mx) return 0;
	else return (mn - mx + 1);
}
int main(){
#ifdef HOME
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ll l1, r1, l2, r2, k;
	cin >> l1 >> r1 >> l2 >> r2 >> k;
	bfs();
	int n = v.size();
	if (n < k){
		puts("0");
	}
	ll ans = 0;
	for (int i = 0; i <= n - k; i++){
		ll x1 = v[i] == 4 ? 1 : v[i - 1] + 1;
		ll y11 = v[i];
		ll x2 = v[i + k - 1];
		ll y2 = (i + k == n) ? (ll)1e9 : v[i + k] - 1;

		ans += intersect(x1, y11, l1, r1) * intersect(x2, y2, l2, r2);
		ans += intersect(x1, y11, l2, r2) * intersect(x2, y2, l1, r1);

	}

	cout << fixed << setprecision(10) << ((double)1.0 *	ans) / ((double) 1.0 * (r1 - l1 + 1) * (r2 - l2 + 1)) << endl;
}

#include <cstdio>
#include <algorithm>
using namespace std;
const int NMAX = 1205;
const int LIM = 1000000001;
int p1, v1, p2, v2, k;
int A[NMAX], r;

void precompute() {
  A[++r] = 4;
  A[++r] = 7;
  for (int i = 1; i <= r; i++) {
    if (1LL * A[i] * 10 + 4 < LIM) {
      A[++r] = A[i] * 10 + 4;
      A[++r] = A[i] * 10 + 7;
    }
  }
}

inline int inters(int l1, int r1, int l2, int r2) {
  return !(r1 < l2 || r2 < l1);
}

inline int no_inters(int l1, int r1, int l2, int r2) {
  return min(r1, r2) - max(l1, l2) + 1;
}

void solve() {
  // padding: first and last
  A[0] = 0;
  A[r + 1] = LIM;

  long long res = 0;
  // start = i => start from [A[start] + 1, A[start + 1]]
  for (int start = 0; start <= r - k; start++) {
    // case 1: first is min
    if (inters(A[start] + 1, A[start + 1], p1, v1) &&
        inters(A[start + k], A[start + k + 1] - 1, p2, v2)) {
      res += 1LL * no_inters(A[start] + 1, A[start + 1], p1, v1) *
        no_inters(A[start + k], A[start + k + 1] - 1, p2, v2);
    }
    // case 2: second is min
    if (inters(A[start] + 1, A[start + 1], p2, v2) &&
        inters(A[start + k], A[start + k + 1] - 1, p1, v1)) {
      res += 1LL * no_inters(A[start] + 1, A[start + 1], p2, v2) *
        no_inters(A[start + k], A[start + k + 1] - 1, p1, v1);
    }
  }

  printf("%.10lf\n", (1.0 * res / (v1 - p1 + 1)) / (v2 - p2 + 1));
}

int main() {
  #ifndef ONLINE_JUDGE
    freopen("input", "r", stdin);
  #endif

  scanf("%d%d%d%d%d", &p1, &v1, &p2, &v2, &k);
  precompute();
  solve();
  return 0;
}

#include <stdio.h>
#include <algorithm>

using namespace std;

int A[1 << 11], size = 0;

void init() {
  A[size++] = 0;
  for (int n = 1; n <= 9; ++n) {
    for (int i = 0; i < (1 << n); ++i) {
      int t = 0;
      for (int j = 0; j < n; ++j) {
        t *= 10;
        if ((i >> (n - j - 1)) & i) t += 7;
        else t += 4;
      }
      A[size++] = t;
    }
  }
  A[size++] = 1000000001;
}

int main() {
  init();
  int pl, pr, vl, vr, k;
  scanf("%d%d", &pl, &pr);
  scanf("%d%d", &vl, &vr);
  scanf("%d", &k);
  double tot = (double) (pr - pl + 1) * (vr - vl + 1);
  double cnt = 0;
  for (int i = 1; i + k < size; ++i) {
    if (pl <= A[i] && A[i + k - 1] <= vr) {
      int al = max(A[i - 1] + 1, pl), ar = min(A[i], pr);
      int bl = max(A[i + k - 1], vl), br = min(A[i + k] - 1, vr);
      if (al <= ar && bl <= br) {
        cnt += (double) (ar - al + 1) * (br - bl + 1);
      }
    }
    if (pl <= A[i + k - 1] && A[i] <= vr) {
      int al = max(A[i - 1] + 1, vl), ar = min(A[i], vr);
      int bl = max(A[i + k - 1], pl), br = min(A[i + k] - 1, pr);
      if (al <= ar && bl <= br) {
        cnt += (double) (ar - al + 1) * (br - bl + 1);
      }
    }
  }
  printf("%.9lf\n", cnt / tot);
  return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>

using namespace std;

const int maxn = 1000*1000*1000;

typedef long long int ullint;

int pl, pr, vl, vr, k;

void read_info(){
    cin >> pl >> pr >> vl >> vr >> k;
}

vector<ullint> nums;

void make(ullint cur){
    if (cur > maxn)
        return;
    nums.push_back(cur);
    make(cur * 10 + 4);
    make(cur * 10 + 7);
}

inline int intersect(int l1, int r1, int l2, int r2){
    return max(0, min(r1, r2) - max(l1, l2) + 1);
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    read_info();
    make(0);
    nums.push_back(maxn);
    sort(nums.begin(), nums.end());
    int n = nums.size();
    long long count = 0;
    for (int i = 1; i < n-k; i++){
        int l1 = nums[i-1]+1, r1 = nums[i];
        int l2 = nums[i+k-1], r2 = nums[i+k]-1;
        int len1 = intersect(l1, r1, vl, vr);
        int len2 = intersect(l2, r2, pl, pr);
        int len3 = intersect(l2, r2, vl, vr);
        int len4 = intersect(l1, r1, pl, pr);
        count += (len1) * (len2);
        count += (len3) * (len4);
    }
    cout.precision(20);
    cout << 1.0 * count / ((pr - pl + 1) * (vr - vl + 1)) << endl;
    return 0;
}

#include<stdio.h>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<deque>
#include<map>
#include<set>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
#define LL long long
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%I64d",&x)
#define all(x) x.begin(),x.end()
#define compress(x) {sort(all(x));(x).resize(unique(all(x))-(x).begin());}
template<class T> inline void umax(T &a,T b){if(a<b) a = b ;}
typedef pair<int, int> ii;
typedef pair<LL, LL> PII;
typedef pair<int, ii> iii;
#define vl vector<ll>
#define vi vector<int>
#define vii vector<ii>
#define vvl vector< vl >
#define vvi vector< vi >
#define vvii vector< vii >
#define sz size()
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mem(x,y) memset(x,y,sizeof(x))
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repv(i,b,a) for(int i=(b);i>=(a);i--)
#define mod 1000000007
#define pb push_back

const int maxn = 100000 + 5;
//const int INF  = 1e9 + 7;
const LL INF = 0x0123456789ABCDEFLL;
vector<LL> luck;
inline void solve(void){
    LL p1 , p2 , v1 , v2 , k;
    cin >> p1 >> p2 >> v1 >> v2 >> k;
    for(int m=9;m>=0;m--){
        int mask = 1 << m;
        rep(i,0,mask){
            LL num = 0;
            rep(j,0,m){
                if(i & (1 << j)) num=num * 10 + 4;
                else num=num*10 + 7;
            }
            if(num>0 && num<=1e9)
            luck.pb(num);
        }
    }
    luck.pb(0) , luck.pb(1e9 );
    sort(all((luck)));
    LL ways = 0;
    for(LL i=1;i + k<luck.sz;i++){
            LL l = i ;
            LL r =  i + k - 1;
            LL prev1 , prev2;
             prev1 = luck[l-1];
             prev2 = luck[r+1];
            l = luck[l], r = luck[r];
            LL x = min(l , p2) - max(p1 , prev1+1) + 1;
            LL  y = min(v2 , prev2-1) - max(r , v1) + 1;
            if(y > 0 && x > 0)
            ways = ways  + x*y;
             x = min(l, v2) - max(v1 , prev1 + 1) + 1;
             y = min(p2 , prev2-1 ) - max(r , p1) + 1;
             if(y > 0 && x > 0)
            ways = ways  + x*y;
        }
        LL tot = (p2-p1+1)* (v2-v1+1);
        double d = tot*1.0;
        double d1 = ways*1.0;
        double ans = d1 / d;
        printf("%.15lf\n", ans);

}
/*void init() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}*/
int main(int argc, const char * argv[]){
    //freopen("rmq.in","r",stdin);
    //freopen("rmq.out","w",stdout);
    //init();
    solve();
    return 0;
}

#ifndef ONLINE_JUDGE
#include "CJP.h"
#endif
//请在此填方案名
#ifndef Lucky_Probability
//////////////////////////////
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>//memset需要
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <deque>
#include <stack>
#include <string>
using namespace std;
//请在此填方案全局部分
__int64 L[10000];
char sa[100];
void makeL(){
	memset(L,0,sizeof L);
	for (int i=1;i<2000;i++)
	{
		int a=i+1;
		itoa(a,sa,2);
		for (int j=1;j<strlen(sa);j++)
		{
			if (sa[j]=='1')
			{
				L[i]+=7;
			}else L[i]+=4;
			L[i]*=10;
		}
		L[i]/=10;
	}
}
////////////////
int main(){
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
#endif
	//请在此填代码
	__int64 i,j,pl,pr,vl,vr,k;
	scanf("%I64d%I64d%I64d%I64d%I64d",&pl,&pr,&vl,&vr,&k);
	makeL();
	__int64 cou=0;
	for (i=0;i<2000;i++)
	{
		if (L[i]>=pl)
		{
			j=i;
			break;
		}
	}
	for(i=pl;i<=pr;i=(pr<=L[j])?pr+1:L[j++]+1)
	{
		__int64 m1=L[j]-i+1,m2=min(L[j+k]-1,vr)-max(L[j+k-1],vl)+1;
		if(m2>0)
			cou+=m1*m2;
	}
	for (i=0;i<2000;i++)
	{
		if (L[i]>=vl)
		{
			j=i;
			break;
		}
	}
	for(i=vl;i<=vr;i=(vr<=L[j])?vr+1:L[j++]+1)
	{
		__int64 m1=L[j]-i+1,m2=min(L[j+k]-1,pr)-max(L[j+k-1],pl)+1;
		if(m2>0)
			cou+=m1*m2;
	}
	/*for (int i=1;i<2000&&L[i-1]<pr;i++)
	{
		if (pl>L[i]||vl>=L[i+k]||vr<L[i+k-1])
		{
			continue;
		}
		__int64 a=min(pr,L[i])-max(L[i-1],pl)+1;
		__int64 b=min(L[i+k],vr)+1-max(vl,L[i+k-1]);
		cou+=a*b;
	}
	for (int i=1;i<2000&&L[i-1]<vr;i++)
	{
		if (vl>L[i]||pl>=L[i+k]||pr<L[i+k-1])
		{
			continue;
		}
		__int64 a=min(vr,L[i])-max(L[i-1],vl)+1;
		__int64 b=min(L[i+k],pr)+1-max(pl,L[i+k-1]);
		cou+=a*b;
	}*/
	printf("%.12f\n",double(cou)/((pr-pl+1)*(vr-vl+1)));
	////////////////////////////
	return 0;
}
#endif
;

#include<bits/stdc++.h>
using namespace std;
#define  mp make_pair
#define fi first
#define se second
vector< long long > v;
void dfs( long long x , int num ){
    if( x != 0 ) v.push_back( x );
    if( num == 9 ) return;
    dfs( x * 10 + 4 , num + 1 );
    dfs( x * 10 + 7 , num + 1 );
}
pair< long long , long long > L[ 1024 ] , R[ 1024 ] ;
pair< long long , long long > seg( pair< long long , long long > p, pair< long long , long long > q ){
    long long mini = max( q.fi , p.fi );
    long long maxi = min( q.se , p.se );
    if( mini > maxi ) return mp( -1LL , -1LL );
    else return mp( mini , maxi );
}
int main(){
    long long pl , pr , vr , vl;
    int k;
    cin>>pl>>pr>>vl>>vr>>k;
    dfs( 0 , 0 );
    sort( v.begin() , v.end() );
    for ( int i = 0 ; i < (int)v.size() ; i++ ){
        if( i != 0 ) L[ i ] = mp( v[ i ] - ( v[ i ] - v[ i - 1 ] ) + 1 , v[ i ] );
        else L[ i ] = mp( -1LL , v[ i ] );
        if( i + 1 != (int)v.size() ) R[ i ] = mp( v[ i ] , v[ i ] + ( v[ i + 1 ] - v[ i ] ) - 1  );
        else R[ i ] = mp( v[ i ] , 200000000000000LL );
    }
    long long ans = 0;
    for ( int i = 0 ; i < (int)v.size() ; i++ ){
        for ( int j = 0 ; j < (int)v.size(); j++ ){
            pair< long long , long long > p = seg( L[ i ] , mp( pl , pr ) );
            pair< long long , long long > q = seg( R[ j ] , mp( vl , vr ) );
            if( (mp( -1LL , -1LL ) != p) && (mp( -1LL , -1LL ) != q ) && ( i + k - 1 == j ) ) ans += ( p.se - p.fi + 1 )*( q.se - q.fi + 1 );
            p = seg( R[ i ] , mp( pl , pr ) );
            q = seg( L[ j ] , mp( vl , vr ) );
            if( (mp( -1LL , -1LL ) != p) && (mp( -1LL , -1LL ) != q ) && ( i - k + 1 == j ) ) ans += ( p.se - p.fi + 1 )*( q.se - q.fi + 1 );

        }
    }
    long long tot = ( vr - vl + 1 )*( pr - pl + 1 );
    printf("%.10f\n",( double)ans/(double)tot );
}

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std ;

double prob(int s1,int e1,int s2,int e2)
{
	int denom = e2-s2+1;
	int s = max(s1,s2);
	int e = min(e1,e2);
	int numer = max(0,e-s+1);
	return numer*1.0/denom;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("prob.in","r",stdin);
#endif
	int c,c2;
	int p1,p2,v1,v2,k;
	scanf("%d%d%d%d%d",&p1,&p2,&v1,&v2,&k);
	vector<int> lucky;
	lucky.push_back(0);
	for (int len=1;len<=9;len++){
		for (int mask=0;mask<(1<<len);mask++){
			int num=0;
			for (int i=len-1;i>=0;i--)
				num=num*10 + 4 + !!(mask&(1<<i))*3;
			lucky.push_back(num);
		}
	}
	lucky.push_back(1+(int)1e9);
	double ret=0;
	for (c=1;c+k<lucky.size();c++){
		ret+= prob(lucky[c-1]+1,lucky[c],p1,p2)*prob(lucky[c+k-1],lucky[c+k]-1,v1,v2);
		ret+= prob(lucky[c-1]+1,lucky[c],v1,v2)*prob(lucky[c+k-1],lucky[c+k]-1,p1,p2);
	}
	printf("%.15lf\n",ret);
	return 0;

}

#include <algorithm>
#include <iterator>
#include <iostream>
#include <sstream>
#include <numeric>
#include <bitset>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <set>
#include <map>

#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>

using namespace std;

typedef long long int64;

const int INF = 2000000000;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

vector< int64 > mas;
int64 pl, pr, vl, vr, k;

void Generate()
{
	mas.push_back(4);
	mas.push_back(7);

	int p = 0; int q = 10;
	while (q < 1000000000)
	{
		int i = p;
		p = mas.size();
		for (; i < p; ++i)
		{
			mas.push_back(4 * q + mas[i]);
			mas.push_back(7 * q + mas[i]);
		}
		q *= 10;
	}
}

bool IsIn(int64 x, int64 l, int64 r)
{
	return x >= l && x <= r;
}

bool F(int64 l1, int64 r1, int64 l2, int64 r2)
{
	return l1 >= l2 && r1 <= r2 || l2 >= l1 && r2 >= r1;
}

int main()
{
	freopen("D.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	Generate();
	mas.push_back(0);
	mas.push_back(1000000001);
	sort(mas.begin(), mas.end());

	cin >> pl >> pr >> vl >> vr >> k;

	double prob = 0;
	//int64 pCnt = 0, vCnt = 0;
	for (int i = 1, j = k; j < mas.size() - 1; ++i, ++j)
	{

		int64 _pl = max(pl, mas[i - 1] + 1);
		int64 _pr = min(pr, mas[i]);
		int64 _vl = max(vl, mas[j]);
		int64 _vr = min(vr, mas[j + 1] - 1);

		int64 _pCnt = 0;
		if (IsIn(_pl, mas[i - 1] + 1, mas[i]) && IsIn(_pr, mas[i - 1] + 1, mas[i])
			&& _pr >= _pl)
			_pCnt = _pr - _pl + 1;

		int64 _vCnt = 0;
		if (IsIn(_vl, mas[j], mas[j + 1] - 1) && IsIn(_vr, mas[j], mas[j + 1] - 1)
			&& _vr >= _vr)
			_vCnt = _vr - _vl + 1;

		prob += (_pCnt / (double) (pr - pl + 1)) * (_vCnt / (double) (vr - vl + 1));

		//printf("%lld %lld | %lld %lld - %lld | %lld ||| ", _pl, _pr, _vl, _vr, _pCnt, _vCnt);

		int64 __pl = max(vl, mas[i - 1] + 1);
		int64 __pr = min(vr, mas[i]);
		int64 __vl = max(pl, mas[j]);
		int64 __vr = min(pr, mas[j + 1] - 1);

		int64 __pCnt = 0;
		if (IsIn(__pl, mas[i - 1] + 1, mas[i]) && IsIn(__pr, mas[i - 1] + 1, mas[i])
			&& __pr >= __pl)
			__pCnt = __pr - __pl + 1;

		int64 __vCnt = 0;
		if (IsIn(__vl, mas[j], mas[j + 1] - 1) && IsIn(__vr, mas[j], mas[j + 1] - 1)
			&& __vr >= __vr)
			__vCnt = __vr - __vl + 1;

		prob += (__pCnt / (double) (vr - vl + 1)) * (__vCnt / (double) (pr - pl + 1));
		if (_pCnt && _vCnt && __pCnt && __vCnt && F(_pl, _pr, _vl, _vr) && F(__pl, __pr, __vl, __vr)) prob -= (1 / (double) (vr - vl + 1)) * (1 / (double) (pr - pl + 1));
		//printf("%lld %lld | %lld %lld - %lld | %lld\n", __pl, __pr, __vl, __vr, __pCnt, __vCnt);

	}
	//cout << mas.size() << endl;
	printf("%.12f\n", min(prob, 1.0));

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define sd(x) scanf("%d", &x)
#define boost ios_base::sync_with_stdio(false);
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define f first
#define s second

typedef pair<int, int> pii;
typedef long long ll;

const int mod = 1000000007;
const int inf = 50000000;
const int maxn = 100010;
const ll lim = 5000000001;

vector<ll> lucky;
int pl, pr, vl, vr;

void generate(ll cur)
{
	lucky.pb(cur);
	ll nxt = cur;
	nxt = nxt*10 + 4;
	if(nxt<lim)
		generate(nxt);
	nxt = cur;
	nxt = nxt*10 + 7;
	if(nxt<lim)
		generate(nxt);
}

ll find_common(ll x1, ll y1, ll x2, ll y2)
{
	ll x, y;
	y = min(y1, y2);
	x = max(x1, x2);
	return max(0ll, y-x+1);
}

int main()
{
	//freopen("i.txt", "r", stdin);
	//freopen("i.txt", "w", stdout);
	generate(0);
	sort(all(lucky));
	int i, k;
	double ans, x, y, p1, p2, cnt1, cnt2;
	ans = 0;
	scanf("%d%d%d%d%d", &pl, &pr, &vl, &vr, &k);
	p1 = (double)1.0/(pr-pl+1);
	p2 = (double)1.0/(vr-vl+1);
	for(i=1; i+k<=lucky.size(); i++){
		if(lucky[i+k-1]>pr && lucky[i+k-1]>vr)
			break;
		cnt1 = find_common(pl, pr, lucky[i-1]+1, lucky[i]);
		cnt2 = find_common(vl, vr, lucky[i+k-1], lucky[i+k]-1);
		x = (double)cnt1*p1;
		y = (double)cnt2*p2;
		ans = (ans+(x*y));
		cnt1 = find_common(pl, pr, lucky[i+k-1], lucky[i+k]-1);
		cnt2 = find_common(vl, vr, lucky[i-1]+1, lucky[i]);
		x = (double)cnt1*p1;
		y = (double)cnt2*p2;
		ans = (ans+(x*y));
	}
	printf("%.12lf\n", ans);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
vector<int> luck;
void lucky(long long v) {
	if (v > 1e9)
		return;
	luck.push_back(v);
	lucky(v * 10 + 4);
	lucky(v * 10 + 7);
}

long long intersect(int a, int b, int x, int y) {
	a = max(a, x);
	b = min(b, y);
	return max(0ll, 1ll * (b - a + 1));

}

int main() {
//	freopen("in.txt", "rt", stdin);
	lucky(4);
	lucky(7);
	int a, b, x, y, k;
	scanf("%d %d %d %d %d", &a, &b, &x, &y, &k);
	luck.push_back(-1);
	luck.push_back(2e9+5);
	sort(luck.begin(), luck.end());
	long long t = 0;
	for (int i = 1; i + k < (int) luck.size(); ++i) {
		t += intersect(a, b, luck[i - 1]+1, luck[i])
				* intersect(x, y, luck[i + k - 1], luck[i + k]-1);
		t += intersect(x, y, luck[i - 1]+1, luck[i])
				* intersect(a, b, luck[i + k - 1], luck[i + k]-1);
	}
	printf("%.20lf", (t * 1.0) / (1.0 * (y - x + 1) * (b - a + 1)));
}

// Made By Haireden Aibyn
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define fname ""
#define INF 2147483647
#define MOD 1000000007
#define sc scanf
#define pr printf
#define pb push_back
#define ex exit(0)
#define tim printf("%.4lf\n", (clock() * 1.) / CLOCKS_PER_SEC)
#define cas printf(""), ex;
#define y1 y4

typedef double ll;
typedef unsigned long long ull;

const int N = 100500;

ll l, r, l1, r1, k;

vector <double> a;

void go(ll v) {
     if (v >= 4e9 || v < 0)
        return;
     a.pb(v);
     go(v * 10 + 4);
     go(v * 10 + 7);

}
int main () {
    srand(time(NULL));
    #ifndef ONLINE_JUDGE
    freopen(fname".in", "r", stdin);
    freopen(fname".out", "w", stdout);
    #endif
    go(0);
    cin >> l >> r >> l1 >> r1 >> k;
    ll kol = 0;
    sort(a.begin(), a.end());
    for (int i = 2; i < a.size(); i++) {
        if (a[i] <= 0)
            continue;
        for (int j = i; j < a.size(); j++) {
            if (j - i + 1 != k) continue;
            ll o1 = max(min(a[i], r) - max(a[i - 1] + 1, l) + 1, 0.0);
            ll o2 = max(min(a[j + 1] - 1, r1) - max(a[j], l1) + 1, 0.0);
            kol += o1 * o2;
            o1 = max(min(a[j + 1] - 1, r) - max(a[j], l) + 1, 0.0);
            o2 = max(min(a[i], r1) - max(a[i - 1] + 1, l1) + 1, 0.0);
            kol += o1 * o2;
            if (k == 1 && l <= a[i] && a[i] <= r && l1 <= a[i] && a[i] <= r1)
                kol--;
        }
    }
    pr("%.9lf", kol / ((r - l + 1) * (r1 - l1 + 1)));
    return 0;
}

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#define MAXN (10000*100000)
using namespace std;
typedef long long int ll;
int digit[2] = {4,7};
vector<int> num;
int p1,p2,v1,v2,k;

void ini(ll x)
{
    if (x*10 > MAXN)return ;
    for (int i(0); i<2; ++i) {
        num.push_back(x*10 + digit[i]);
        ini(x*10 + digit[i]);
    }
    return ;
}

double get_num(int si, int di)
{
    double ans = 0;
    if (p1 <= num[si] && v2 >= num[di]) {
       ans += (min(p2-p1,num[si]-p1) + 1)*(min(v2-v1,v2-num[di]) + 1);
    }
    //cout<<ans<<endl;
    if (v1 <= num[si] && p2 >= num[di]) {
       ans += (min(v2-v1,num[si]-v1) + 1)*(min(p2-p1,p2-num[di]) + 1);
    }
    //cout<<ans<<endl;
    return ans;
}

int main()
{
    scanf("%d%d%d%d%d",&p1,&p2,&v1,&v2,&k);
    ini(0);
    sort(num.begin(),num.end());
    int now(-1),end(-1);
    for (int i(0); i<num.size(); ++i) {
        if (num[i] > max(p2,v2)) {
           end = i;
           break;
        }
        if (now != -1)continue;
        if (num[i] <= max(p2,v2) && num[i] >= min(p1,v1)) {
           now = i;
        }
    }
    if (now == -1) {
       cout<<0.000000<<endl;
       return 0;
    } else {
       if (end == -1)end = num.size();
       if (end - now < k) {
          cout<<0.0000000<<endl;
          return 0;
       }
    }
    //for (int i(now); i<end; ++i)cout<<num[i]<<" ";
    //cout<<endl;
    double ans = 0;
    for (int i(now); i<end && i+k-1<end; ++i) {
        int j = i + k - 1;
        ans += get_num(i, j);
    }
    //cout<<ans<<endl;
    double div = (p2 - p1 + 1);
    div *= (v2 - v1 + 1);
    ans /= div;
    printf("%.6lf\n",ans);
    //system("pause");
    return 0;
}

#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;

typedef long long ll;

ll luc[ 1000000 ];
int cont = 3;

void gerar(){
    luc[ 0 ] = 0;
    luc[ 1 ] = 4;
    luc[ 2 ] = 7;
    int qtd = 2;
    ll pot = 10;
    int ini = 1;

    bool sair = false;
    while( !sair ){
        for( int i = ini; i < ini + qtd; ++i )
            luc[ cont++ ] = pot * 4 + luc[ i ];
        for( int i = ini; i < ini + qtd; ++i )
            luc[ cont++ ] = pot * 7 + luc[ i ];
        if( luc[ cont - 1 ] > 2000000000 ) sair = true;
        ini += qtd;
        qtd *= 2;
        pot *= 10;
    }

}

int main(){
    ll pr, pl, vr, vl;
    double soma = 0;
    int k;
    gerar();

    scanf( "%lld %lld %lld %lld %d", &pl, &pr, &vl, &vr, &k );
    int prt = 1;

    while( luc[ prt + k - 1 ] <= pr || luc[ prt + k - 1 ] <= vr ){
        ll il, fl, ir, fr;

        //Tirando o menor de P
        il = max( luc[ prt - 1 ] + 1, pl );
        fl = min( luc[ prt ], pr );
        //e portanto o maior de V
        ir = max( luc[ prt + k - 1 ], vl );
        fr = min( luc[ prt + k ] - 1, vr );
        if( il <= fl && ir <= fr )
            soma += ( fl - il + 1 ) * ( fr - ir + 1 );

        //Tirando o MAIOR de P
        il = max( luc[ prt - 1 ] + 1, vl );
        fl = min( luc[ prt ], vr );
        //e portanto o menor de V
        ir = max( luc[ prt + k - 1 ], pl );
        fr = min( luc[ prt + k ] - 1, pr );

        if( il <= fl && ir <= fr )
            soma += ( fl - il + 1 ) * ( fr - ir + 1 );

        ++prt;
    }
    //printf( "Soma %lld\n", soma );
    double resp = soma / ( ( pr - pl + 1 ) * ( vr - vl + 1 ) );
    cout << resp << endl;
}

#include<stdio.h>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<deque>
#include<map>
#include<set>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
#define LL long long
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%I64d",&x)
#define all(x) x.begin(),x.end()
#define compress(x) {sort(all(x));(x).resize(unique(all(x))-(x).begin());}
template<class T> inline void umax(T &a,T b){if(a<b) a = b ;}
typedef pair<int, int> ii;
typedef pair<LL, LL> PII;
typedef pair<int, ii> iii;
#define vl vector<ll>
#define vi vector<int>
#define vii vector<ii>
#define vvl vector< vl >
#define vvi vector< vi >
#define vvii vector< vii >
#define sz size()
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mem(x,y) memset(x,y,sizeof(x))
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repv(i,b,a) for(int i=(b);i>=(a);i--)
#define mod 1000000007
#define pb push_back

const int maxn = 100000 + 5;
//const int INF  = 1e9 + 7;
const LL INF = 0x0123456789ABCDEFLL;
vector<LL> luck , lucky;
inline void solve(void){
    LL p1 , p2 , v1 , v2 , k;
    cin >> p1 >> p2 >> v1 >> v2 >> k;
    for(int m=9;m>=0;m--){
        int mask = 1 << m;
        rep(i,0,mask){
            LL num = 0;
            rep(j,0,m){
                if(i & (1 << j)) num=num * 10 + 4;
                else num=num*10 + 7;
            }
            if(num>0)
            luck.pb(num);
        }
    }
    sort(all((luck)));
    LL ways = 0;
    for(int i=k-1;i<luck.sz;i++){
            LL l = i - (k - 1);
            LL r =  i;
            LL prev1 , prev2;
            if(l==0) prev1=0;
            else prev1 = luck[l-1];
            if(r==luck.sz) prev2 = INF;
            else prev2 = luck[i+1];
            l = luck[l] , r = luck[r];
            LL x = min(l , p2) - max(p1 , prev1+1) + 1;
            if(x <=  0) continue;
            LL  y = min(v2 , prev2-1) - max(r , v1) + 1;
            if(y <= 0) continue;
            ways = ways  + x*y;
             x = min(l, v2) - max(v1 , prev1 + 1) + 1;
            if(x <=  0) continue;
              y = min(p2 , prev2-1) - max(r , p1) + 1;
            if(y <= 0) continue;
            ways = ways  + x*y;
        }
        LL tot = (p2-p1+1)* (v2-v1+1);
        double d = tot*1.0;
        double d1 = ways*1.0;
        double ans = d1 / d;
        printf("%.15lf\n", ans);

}
/*void init() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}*/
int main(int argc, const char * argv[]){
    //freopen("rmq.in","r",stdin);
    //freopen("rmq.out","w",stdout);
    //init();
    solve();
    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long int lint;

int main()
{
  cout.setf(ios::fixed);
  cout.precision(12);
  vector<lint> v;
  v.push_back(4);
  v.push_back(7);
  for (int i=0;i<10;i++) {
    int tope=int(v.size());
    for (int j=0;j<tope;j++) {
      lint val=v[j];
      v.push_back(10*val+4);
      v.push_back(10*val+7);
    }
  }
  v.push_back(0);
  sort(v.begin(),v.end());
  lint pl,pr,vl,vr,k;
  cin>>pl>>pr>>vl>>vr>>k;
  lint favorables=0;
  lint posibles=(pr-pl+1)*(vr-vl+1);
  int inext=0;
  for (int i=0;i<int(v.size())-2;i++) {
    while (inext<int(v.size())-1 and inext-i<k) inext++;
    if (inext==int(v.size())-1) break;
    {
      lint left1=v[i]+1;
      lint right1=v[i+1];
      lint left2=v[inext];
      lint right2=v[inext+1]-1;
      lint rango1=min(right1,pr)-max(left1,pl)+1;
      if (rango1<0) rango1=0;
      lint rango2=min(right2,vr)-max(left2,vl)+1;
      if (rango2<0) rango2=0;
      lint rangocomun=min(min(right1,pr),min(right2,vr))-
	max(max(left1,pl),max(left2,vl))+1;
      if (rangocomun<0) rangocomun=0;
      favorables+=rango1*rango2-2*rangocomun;
    }
    {
      lint left2=v[i]+1;
      lint right2=v[i+1];
      lint left1=v[inext];
      lint right1=v[inext+1]-1;
      lint rango1=min(right1,pr)-max(left1,pl)+1;
      if (rango1<0) rango1=0;
      lint rango2=min(right2,vr)-max(left2,vl)+1;
      if (rango2<0) rango2=0;
      lint rangocomun=min(min(right1,pr),min(right2,vr))-
	max(max(left1,pl),max(left2,vl))+1;
      if (rangocomun<0) rangocomun=0;
      favorables+=rango1*rango2-rangocomun;
    }
  }
  cout<<double(favorables)/double(posibles)<<endl;
}

#include <stdlib.h>
#include <string.h>
#include <vector>
#include <map>
#include <list>
#include <map>
#include <set>
#include <fstream>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <limits.h>
#define _USE_MATH_DEFINES
#include <math.h>

#define pb(a) push_back(a)
#define sz size()
#define ALL(a) a.begin(),a.end()
#define ALLR(a) a.rbegin(),a.rend()
#define X first
#define Y second

typedef long long ll;
typedef double ld;

template<typename T> inline void SWAP(T &a, T &b){T tmp=a;a=b;b=tmp;}
template<typename T> inline T ABS(const T &val) {return val<0?-val:val;}
template<typename T> inline T MAX(const T &a, const T &b){return a>b?a:b;}
template<typename T> inline T MIN(const T &a, const T &b){return a<b?a:b;}
template<typename T> inline T SQR(const T &a){return a*a;}

#define MSET(d) memset(d,0,sizeof(d))
#define forn(i,n) for(int i=0;i!=n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forab(i,a,b) for(int i=a;i!=b;i++)
#define for1ab(i,a,b) for(int i=a+1;i<=b;i++)
#define fordab(i,a,b) for(int i=b-1;i>=a;i--)
#define ford1ab(i,a,b) for(int i=b;i!=a;i--)
#define ford(i,n) for(int i=n-1;i!=-1;i--)
#define ford1(i,n) for(int i=n;i!=0;i--)

const int INTinf=2147483647;
const int nINTinf=0-2147483648;
#define LLinf 9223372036854775807

using namespace std;
typedef pair<int, int> pii;
ll v1, v2, p1, p2, rez;
int k;
ll mass[1050];
int cnt=0;
vector<int> getFirstLuck (ll from){
	vector<int> vc;
	while (from!=0){
		int tmp = from%10;
		from/=10;
		if (tmp>7){
			tmp=4;
			from++;
		}else
		if  (tmp<4){
			tmp=4;
		} else tmp=7;
		vc.pb(tmp);
		from/=10;
	}
	return vc;
}
void getNext(vector<int> &vc){
	int i=0;
	while (i!=vc.sz){
		if (vc[i]==4){
			vc[i]=7;
			return;
		}
		vc[i]=4;
		i++;
	}
	vc.pb(4);
}
ll getNom(vector<int> &vc){
	ll rez=0;
	ford(i,vc.sz){
		rez*=10;
		rez+=vc[i];
	}
	return rez;
}
void gen(ll from, ll to){
	vector<int> now = getFirstLuck(from);
	ll tmp = getNom(now);
	if (tmp==from) getNext(now);
	while ((tmp=getNom(now))<=to){
		mass[cnt++]=tmp;
		getNext(now);
	}
}

inline ll getKol(const int &val1, const int &val2, const int &v1, const int &v2){
	int last = MIN(v2, val2);
	int f = MAX(val1, v1);
	f--;
	if (last>f) return last-f;
	return 0;
}
int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
#endif
	cin>>v1>>v2>>p1>>p2>>k;
	rez=0;
	gen(MIN(v1,p1)-1, MAX(v2, p2));
	if (cnt<k){
		cout<<0<<endl;
		return 0;
	}
	ll allR = (v2-v1+1)*(p2-p1+1);
	ll needR = 0;
	int pos=0;
	int last=pos+k-1;
	while (last!=cnt){
		ll r1 = getKol(pos!=0? mass[pos-1]+1:-5, mass[pos], v1, v2);
		ll r2;
		if (r1) {
			r2 = getKol(mass[last], last+1!=cnt?mass[last+1]-1:1000000006, p1, p2);
			needR+=r1*r2;
		}
		r1 = getKol(pos!=0? mass[pos-1]+1:-5, k==1? mass[pos]-1:mass[pos], p1, p2);
		if (r1) {
			r2 = getKol(mass[last], last+1!=cnt?mass[last+1]-1:1000000006, v1, v2);
			needR+=r1*r2;
		}
		pos++;
		last++;
	}
	cout.setf(ios_base::fixed);
	cout.precision(11);
	ld rez = needR;
	rez/=allR;
	cout<<rez<<endl;

	return 0;
}

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

vector <long long int >v;

int main()
{
	long long int pl,pr,vl,vr,l,r,a,b,c,d,e,f,g,h,ans=0,k,i,j;
	v.push_back(4);
	v.push_back(7);
	i=0;
	while(i<v.size())
	{
		j=v[i];
		if(j*10+4<=1000000000000)
			v.push_back(j*10+4);
		if(j*10+7<=1000000000000)
			v.push_back(j*10+7);
		i++;
	}
	cin>>pl>>pr>>vl>>vr>>k;
	if(k==1)
	{
		g=0;
		h=0;
		for(i=0;i<v.size();i++)
		{
			if(v[i]>=pl && v[i]<=pr)
				g++;
			if(v[i]>=vl && v[i]<=vr)
				h++;
		}
		ans+=h*g;
		double finans=(double)ans/((double)((pr-pl+1)*(vr-vl+1)));
		printf("%.9lf",finans);
		return 0;
	}
	for(i=0;i<v.size()-k;i++)
	{
		if(i==0)
			a=1;
		else
			a=v[i-1]+1;
		b=v[i];
		c=v[i+k-1];
		d=v[i+k]-1;
		e=max(a,pl);
		f=min(b,pr);
		g=max(f-e+1,0LL);
		e=max(c,vl);
		f=min(d,vr);
		h=max(f-e+1,0LL);
		ans+=g*h;
		e=max(a,vl);
		f=min(b,vr);
		g=max(f-e+1,0LL);
		e=max(c,pl);
		f=min(d,pr);
		h=max(f-e+1,0LL);
		ans+=g*h;
	}
	//cout<<ans;
	double finans=(double)ans/((double)((pr-pl+1)*(vr-vl+1)));
	printf("%.9lf",finans);
	return 0;
}

#ifndef ONLINE_JUDGE
#include "CJP.h"
#endif
//请在此填方案名
#ifndef Lucky_Probability
//////////////////////////////
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>//memset需要
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <deque>
#include <stack>
#include <string>
using namespace std;
//请在此填方案全局部分
__int64 L[10000];
char sa[100];
void makeL(){
	memset(L,0,sizeof L);
	for (int i=1;i<2000;i++)
	{
		int a=i+1;
		itoa(a,sa,2);
		for (int j=1;j<strlen(sa);j++)
		{
			if (sa[j]=='1')
			{
				L[i]+=7;
			}else L[i]+=4;
			L[i]*=10;
		}
		L[i]/=10;
	}
}
////////////////
int main(){
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
#endif
	//请在此填代码
	__int64 i,j,pl,pr,vl,vr,k;
	scanf("%I64d%I64d%I64d%I64d%I64d",&pl,&pr,&vl,&vr,&k);
	makeL();
	__int64 cou=0;
	for (i=0;i<2000;i++)
	{
		if (L[i]>=pl)
		{
			j=i;
			break;
		}
	}
	for(i=pl;i<=pr;i=((pr<=L[j])?pr:L[j++])+1)
	{
		__int64 m1=min(pr,L[j])-i+1,m2=min(L[j+k]-1,vr)-max(L[j+k-1],vl)+1;
		if(m2>0)
			cou+=m1*m2;
	}
	for (i=0;i<2000;i++)
	{
		if (L[i]>=vl)
		{
			j=i;
			break;
		}
	}
	for(i=vl;i<=vr;i=((vr<=L[j])?vr:L[j++])+1)
	{
		__int64 m1=min(vr,L[j])-i+1,m2=min(L[j+k]-1,pr)-max(L[j+k-1],pl)+1;
		if(m2>0)
			cou+=m1*m2;
	}
	/*for (int i=1;i<2000&&L[i-1]<pr;i++)
	{
		if (pl>L[i]||vl>=L[i+k]||vr<L[i+k-1])
		{
			continue;
		}
		__int64 a=min(pr,L[i])-max(L[i-1],pl)+1;
		__int64 b=min(L[i+k],vr)+1-max(vl,L[i+k-1]);
		cou+=a*b;
	}
	for (int i=1;i<2000&&L[i-1]<vr;i++)
	{
		if (vl>L[i]||pl>=L[i+k]||pr<L[i+k-1])
		{
			continue;
		}
		__int64 a=min(vr,L[i])-max(L[i-1],vl)+1;
		__int64 b=min(L[i+k],pr)+1-max(pl,L[i+k-1]);
		cou+=a*b;
	}*/
	printf("%.12f\n",double(cou)/((pr-pl+1)*(vr-vl+1)));
	////////////////////////////
	return 0;
}
#endif
;

#include <stdio.h>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <algorithm>
#define FOR(A, B) for(A=0;A<B;A++)

using namespace std;
vector<long long> luckies;
int l;
int lim1,lim2;
void gen(long long c)
{
	if(c > lim2) return;
	if(l > 0 && c >= lim1) luckies.push_back(c);
	l++;
	gen(c*10+4);
	gen(c*10+7);
	l--;
}

int getluckiesin(int s, int e)
{
	int i;
	int ans = 0;
	FOR(i, luckies.size()) {
		if(luckies[i] >= s && luckies[i] <= e) ans++;
	}
	return ans;
}

int main()
{
	int i, j, k, n, m, pl, pr, vl, vr;
	scanf("%d %d %d %d %d", &pl, &pr, &vl, &vr, &k);
	if(pl < vl) {
		int tmp = pl; pl = vl; vl = tmp;
		tmp = pr; pr = vr; vr = tmp;
	}
	l = 0; lim1=min(vl, pl); lim2 = max(vr, pr);
	gen(0);
	long double total = (long double)(vr-vl+1)*(long double)(pr-pl+1);
	long double positive = 0.0;
	int prevstart = min(vl, pl);
	FOR(i, luckies.size()) {
		int prevend = max(pr, vr);
		for(j = luckies.size()-1; j>=i; j--) {
			int lucks = (j-i+1);
			if(lucks == k) {
//				printf("lucks==k! (i=%d, j=%d, luckies[i]=%lld, luckies[j]=%lld, prevstart=%d, prevend=%d)\n", i, j, luckies[i], luckies[j], prevstart, prevend);
				if(i != j) positive += 2*(luckies[i]-prevstart+1)*(prevend-luckies[j]+1);
				else positive += (luckies[i]-prevstart)*(prevend-luckies[j]);
			}
			prevend = luckies[j];
		}
		prevstart = luckies[i];
	}
//	printf("%Lf\n", positive);
	printf("%.10lf\n", (double)(positive/total));
	return 0;
}

#pragma comment(linker,"/STACK:16777216")
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<cstring>
#include<ctime>
#include<cmath>
#include<functional>

using namespace std;

#define ll long long
#define ld long double
#define si short int
#define pii pair<int,int>
#define vi vector<int>
#define vit vector<int>::iterator
#define sq(x) (x)*(x)

double prob_before(int a, int b, int ser)
{
	if(ser<a)
		return 0.0;
	if(ser>=b)
		return 1.0;
	return (ser-a+1)/(double)(b-a+1);
}

double prob_after(int a, int b, int ser)
{
	if(ser<=a)
		return 1.0;
	if(ser>b)
		return 0.0;
	return (b-ser+1)/(double)(b-a+1);
}

ll makeit(int a)
{
	ll answ = 0;
	ll mnoj = 1;
	while(a>1)
	{
		if(a&1)
			answ+=7*mnoj;
		else
			answ+=4*mnoj;
		a>>=1;
		mnoj*=10;
	}
	return answ;
}

int main()
{
	vector<ll> happy;
	happy.push_back(-1);
	happy.push_back(1000000001);
	ll curr4 = 40, curr7 = 70;
	int stop = 0;
	int from = 1;
	/*for(;curr4<1000000000; curr4*=10, curr7*=10)
	{
		for(int j=from; j>=stop; --j)
		{
			happy.push_back(curr4 + happy[j]);
			happy.push_back(curr7 + happy[j]);
		}
		stop = from+1;
		from = happy.size()-1;
	}*/
	for(int i=2; i<4096; ++i)
		happy.push_back(makeit(i));
	sort(happy.begin(),happy.end());
	//cout<<happy.size()<<endl;
	//freopen("out.txt","w",stdout);
	/*for(int i=0; i<happy.size(); ++i)
		cout<<happy[i]<<endl;*/
	int a1,b1,a2,b2,k;
	cin>>a1>>b1>>a2>>b2>>k;
	double res = 0.0;
	if(k>1)
		for(int i=1; i+k<happy.size(); ++i)
		{
			res+=prob_before(a1,b1,happy[i])*prob_after(a2,b2,happy[i+k-1]) * prob_before(a2,b2,happy[k+i]-1)*prob_after(a1,b1,happy[i-1]+1);
			res+=prob_before(a2,b2,happy[i])*prob_after(a1,b1,happy[i+k-1]) * prob_before(a1,b1,happy[k+i]-1)*prob_after(a2,b2,happy[i-1]+1);
		}
	else
	{
		for(int i=1; i+k<happy.size(); ++i)
		{
			res+=prob_before(a1,b1,happy[i])*prob_after(a2,b2,happy[i]) * prob_before(a2,b2,happy[1+i]-1)*prob_after(a1,b1,happy[i-1]+1);
			res+=prob_before(a2,b2,happy[i])*prob_after(a1,b1,happy[i]+1) * prob_before(a1,b1,happy[1+i]-1)*prob_after(a2,b2,happy[i-1]+1);
		}
	}
	/*int i=0;
	res+=prob_before(a1,b1,happy[i])*prob_after(a2,b2,happy[i+k-1]) * prob_before(a2,b2,happy[k+i]-1)*prob_after(a1,b1,-10000+1);
	res+=prob_before(a2,b2,happy[i])*prob_after(a1,b1,happy[i+k-1]) * prob_before(a1,b1,happy[k+i]-1)*prob_after(a2,b2,-10000+1);
	i=(int)happy.size() - k;
	if(i>=0)
	{
		res+=prob_before(a1,b1,happy[i])*prob_after(a2,b2,happy[i+k-1]) * prob_before(a2,b2,1000000001)*prob_after(a1,b1,happy[i-1]+1);
		res+=prob_before(a2,b2,happy[i])*prob_after(a1,b1,happy[i+k-1]) * prob_before(a1,b1,1000000001)*prob_after(a2,b2,happy[i-1]+1);
	}*/
	printf("%.9lf\n",res);
	return 0;
}

//made by capeta160
#include<iostream>
#include<cmath>
#include<iomanip>
#include<list>
#include<climits>
#include<cstring>
#include<set>
#include<unordered_set>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<numeric>
using namespace std;
#define etm cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n'
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define doub long double
#define mp make_pair
#define pb push_back
#define pii pair<int , int>
#define pdd pair<double , double>
#define pll pair<long long int,long long int>
#define vpl vector<pll >
#define vll vector<ll >
#define vb vector<bool>
#define vvbb vector<vb>
#define vi vector<int >
#define mi map<int, int>
#define mull map<ull, ull>
#define stp setprecision(20)
#define N 100005
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define ld                      long double
#define inf                     1e18
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define vvll                    vector<vector<ll>>
#define vvii			vector<vector<int>>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define print(a)                cout<<a<<"\n";
#define pqll                    priority_queue<ll>
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define umll                    unordered_map<ll,ll>
#define mll                     map<ll,ll>
#define input(a,n)              ll I;rep(I,0,n-1,1) cin>>a[I];
#define countbit                __builtin_popcount // Number of set bits .
#define fbo(k)                  find_by_order // K-th element in a set (counting from zero) .
#define ook(k)                  order_of_key //  Number of items strictly smaller than k .
#define lb                      lower_bound
#define up                      upper_bound
#define in                      insert
//#define db(x) cout <<#x<<": "<<x<<'\n';
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
ll gcd(ll a,ll b){if(a<b)return gcd(b,a);else if(b==0)return a;else return gcd(b,a%b);}
ll isPrime(ll n){ll p=(ll)sqrt(n);rep(i,2,p,1) if(n%i==0) return 0;return 1;}// reuturn 1 if prime
ll pow(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll ceil(long double a){ll b=a;if(a==b){return b;}else{return b+1;}}
ll floor(long double a){ll b=a;return b;}
ll lcm(ll a,ll b){ return (a*b)/gcd(a,b);}
ll modInverse(ll a, ll m) { return powm(a, m-2, m);}
bool issq(ll n){ ll p=sqrt(n);return p*p==n;}
vll prime;// if i==prime[i] then prime otherwise smallest prime factor of that number
void sieve(ll n)
{
    prime.resize(n+1,1);
    prime[0] = 0, prime[1] = 0;
    for (ll i = 2; i*i <= n; i++)
        if (prime[i])
            for (ll j = i * i; j <= n; j += i)
                prime[j] = 0;
}
ll extended_GCD(ll a ,ll b ,ll &x ,ll &y){
    if(a == 0){
        x = 0;
        y = 1;
        return b;
    }
    ll x1 , y1;
    ll gcd = extended_GCD(b%a , a , x1 , y1);
    x = y1 - (b/a)*x1;
    y = x1;
    return gcd;
}
    ll mulInv(ll a , ll mod=26){
    ll x , y;
    extended_GCD(a , mod , x , y);
    if(x < 0) x += mod;
    return x;
}
ll find(ll num[], ll rem[], ll k,ll prod)
{
    // Compute product of all numbers
    ll result = 0;
    // Apply above formula
    for (ll i = 0; i < k; i++)
    {
        ll pp = prod / num[i];
        result += rem[i] * mulInv(pp, num[i]) * pp;
    }
    return result % prod;
}
ll nCr(ll n,ll k)
{
  ll res = 1;

      // Since C(n, k) = C(n, n-k)
      if ( k > n - k )
          k = n - k;

      // Calculate value of
      // [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]
      for (ll i = 0; i < k; ++i)
      {
          res *= (n - i);
          res /= (i + 1);
      }

      return res;
}
class DSU
{
 public:vll parent,size;
public: DSU(ll n)
{

        parent.resize(n+1);size.resize(n+1);
        for(ll i=1;i<=n;i++)
            {
            parent[i]=i;
            size[i]=1;
          }
    }
public:ll find_set(ll x)
    {
      if(parent[x]==x)
      {
        return x;
      }
      return parent[x]=find_set(parent[x]);
    }
public:void union_set(ll x,ll y)
    {
        x=find_set(x);y=find_set(y);
        if(x!=y)
        {
          parent[y]=x;
        }
}
};
bool cmp(pair<ll,ll>&p1,pair<ll,ll>&p2)
{
  if(p1.fi==p2.fi)
  {
    return p1.se>p2.se;
  }
  return p1.fi>p2.fi;
}
bool isPalindrome(string s)
{
  ll i,j;
  for(i=0,j=s.length()-1;i<=j;i++,j--)
  {
    if(s[i]!=s[j])
    {
      return 0;
    }
  }
return 1;
}
ll ToInt(char ch)
{
  return ch-'0';
}
char ToChar(ll a)
{
  return a+'0';
}
bool isSubSeq(string str1, string str2, ll m, ll n)
{
    // Base Cases
    if (m == 0) return true;
    if (n == 0) return false;
    // If last characters of two strings are matching
    if (str1[m-1] == str2[n-1])
        return isSubSeq(str1, str2, m-1, n-1);
    // If last characters are not matching
    return isSubSeq(str1, str2, m, n-1);
}
void printVectorPair(vpll v)
{
  for(ll i=0;i<v.size();i++)
  {
    cout<<v[i].fi<<" "<<v[i].se<<"\n";
  }
}
void modBigNumber(string num, ll m)
{
    // Store the modulus of big number
    vector<int> vec;
    ll mod = 0;
    // Do step by step division
    for (int i = 0; i < num.size(); i++) {
        int digit = num[i] - '0';
        mod = mod * 10 + digit;
        int quo = mod / m;
        if((vec.size()!=0)||(quo!=0))        //to remove initiale zeros
        vec.push_back(quo);
        mod = mod % m;
    }
   // cout << "\nRemainder : " << mod << "\n";
   // cout << "Quotient : ";rep(i,0,vec.size()-1,1)cout<<vec[i];cout<<"\n";
    return;
}
struct SegmentTree
{
  ll n;
  vll v;
  SegmentTree(ll size)
  {
    n=4*size+1;
    v.resize(n,0);
  }
  void build(ll ar[],ll ipos,ll fpos,ll pos=1)
  {
    if(ipos>fpos)
    return ;
    if(ipos==fpos)
    v[pos]=ar[ipos];
    else
    {
    ll mid=(ipos+fpos)/2;
    build(ar,ipos,mid,pos*2);
    build(ar,mid+1,fpos,pos*2+1);
    v[pos]=v[pos*2]+v[pos*2+1];
    }
  }
  void update(ll index,ll val,ll ipos,ll fpos,ll pos=1)
  {
    if(ipos>fpos)
    return ;
    if(ipos==fpos)
    v[pos]+=val;
    else
    {
      v[pos]+=val;
      ll mid=(ipos+fpos)/2;
      if(mid>=index)
      update(index,val,ipos,mid,pos*2);
      else
      update(index,val,mid+1,fpos,pos*2+1);
    }
  }
  ll get_sum(ll l,ll r,ll ipos,ll fpos,ll pos=1)
  {
    if(ipos>fpos)
    return 0;
    if(l>r)
    return 0;
    ll mid=(ipos+fpos)/2;
    if((l==ipos)&&(r==fpos))
    return v[pos];
    else return get_sum(l,min(mid,r),ipos,mid,pos*2)+get_sum(max(mid+1,l),r,mid+1,fpos,pos*2+1);
  }
};
struct BIT
{
vector<ll>bitree;ll n;
BIT(ll n)
{
this->n=n;
bitree.resize(n+1,0);
}
void update(ll idx,ll val)
{
  idx++;
  while(idx<=n)
  {
    bitree[idx]+=val;
    idx+=idx&(-idx);
  }
}
ll Sum(ll idx)
{
  ll sum=0;
  idx++;
  while(idx>0)
  {
    sum+=bitree[idx];
    idx-=idx&(-idx);
  }
  return sum;
}
};
ll sumofdigits(ll a)
{
  ll val=0;
  while(a>0)
  {
    val+=a%10;
    a/=10;
  }
  return val;
}

vll cntdig(ll n){
  vll ans;
  while(n>0){
    ans.pb(n%10);
    n/=10;
  }
  reverse(all(ans));
  return ans;
}

/*
ideas
1)Find all the lucky numbers
*/

vll lucky;
void go(ll dig=0, ll num=0){
  if(dig>=11)return ;
  lucky.pb(num*10+4);
  lucky.pb(num*10+7);
  go(dig+1, num*10+4);
  go(dig+1, num*10+7);
}

int main(){
  fastio;
  lucky.pb(0);
  go();
  sort(all(lucky));
  ll pl, pr, vl, vr, k;cin>>vl>>vr>>pl>>pr>>k;
  ll st=min(pl, min(pr, min(vl, vr))), ed=max(pl, max(pr, max(vl, vr)));
  ll pos=lower_bound(all(lucky), st)-lucky.begin(), re=pos+k-1;
  // cout<<pos<<re<<endl;
  ll cnt=0;

  while(lucky[re]<=ed){
    // cout<<lucky[pos]<<" "<<lucky[re]<<endl;
    cnt+=((min(vr, lucky[re+1]-1)-max(vl, lucky[re])+1)<0?0:(min(vr, lucky[re+1]-1)-max(vl, lucky[re])+1))*((min(lucky[pos], pr)-max(pl, lucky[pos-1])+1)<0?0:(min(lucky[pos], pr)-max(pl, lucky[pos-1]+1)+1));
    cnt+=((min(pr, lucky[re+1]-1)-max(lucky[re], pl)+1)<0?0:(min(pr, lucky[re+1]-1)-max(lucky[re], pl)+1))*((min(vr, lucky[pos])-max(vl, lucky[pos-1]+1)+1)<0?0:(min(vr, lucky[pos] )-max(vl, lucky[pos-1]+1)+1));
    cout<<((min(pr, lucky[re+1])-max(lucky[re], pl)+1)<0?0:(min(pr, lucky[re+1])-max(lucky[re], pl)+1))<<" "<<(min(vr, lucky[pos])-max(vl, lucky[pos-1]+1)+1)<<endl;
    re++;pos++;
  }
  // cout<<re<<endl;
  cout<<fixed<<setprecision(12)<<(double)cnt/(double)((pr-pl+1)*(vr-vl+1))<<endl;
  return 0;
}

#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <utility>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
#define two(X) (1<<(X))
#define twoL(X) (((int64)(1))<<(X))
#define contain(S,X) ((S&two(X))>0)
#define containL(S,X) ((S&twoL(X))>0)
typedef pair<int,int> PIIS;
int countbit(int n) {return (n==0)?0:(1+countbit(n&(n-1)));}
int lowbit(int n) {return (n^(n-1))&n;}
const double pi=acos(-1.0);
const double eps=1e-11;
template<class T> T sqr(T x) {return x*x;}
template<class T> void checkmin(T &a,T b) {if (b<a) a=b;}
template<class T> void checkmax(T &a,T b) {if (b>a) a=b;}
#define SIZE(X) ((int)((X).size()))
#define LENGTH(X) ((int)((X).length()))
#define MP(A,B) make_pair(A,B)

set<int> lucky;
vector<int> L;

void init( LL n )
{
	if( n )
		lucky.insert( n );
	if( n < 100000000 )
	{
		init( n * 10 + 4 );
		init( n * 10 + 7 );
	}
}

int main()
{
#if	_MSC_VER == 1500
	freopen( "in.txt", "r", stdin );
#endif
	// code here
	int pl, pr, vl, vr, k;
	cin >> pl >> pr >> vl >> vr >> k;
	init( 0 );
	L.assign( lucky.begin(), lucky.end() );
	int len = L.size();
	double ans = 0;
	for( int i = 0; i + k <= len; ++ i )
	{
		int left = L[i], right = L[i + k - 1];
		if( pl <= left && vr >= right )
			ans += double( min( left, pr ) - pl + 1 ) / ( pr - pl + 1 ) * ( vr - max( vl, right ) + 1 ) / ( vr - vl + 1 );
		if( vl <= left && pr >= right )
			ans += double( min( left, vr ) - vl + 1 ) / ( vr - vl + 1 ) * ( pr - max( pl, right ) + 1 ) / ( pr - pl + 1 );
	}
	printf( "%.8lf\n", ans );
	return 0;
}

#include <string>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <sstream>
#include<cmath>
#include<algorithm>
#include<fstream>
#include<cstring>
using namespace std;
# define FOR(i,a,n) for(int i=a;i<n;++i)
# define REP(i,n) FOR(i,0,n)
typedef long long LL;
vector<LL> v;
void calc(int num)
{
	if(num) v.push_back(num);
	if(num*4LL>=1000000000LL) return;
	calc(num*10+4);
	calc(num*10+7);
}
int main()
{
	calc(0);
	LL a,b,c,d,k,den;
	double ans=0;
	cin>>a>>b>>c>>d>>k;
	den=(b-a+1)*(d-c+1);
	v.push_back(0);v.push_back(1000000001);
	sort(v.begin(),v.end());
	int n=v.size();
	for(int i=1,j=k;j<n-1;++i,++j)
	{
		LL x,y;
		if(a<=v[i]) {
		x=min(b,v[i])-max(v[i-1]+1,a)+1;
		if(d>=v[j])
		if(c<v[j+1]) {
		y=min(v[j+1]-1,d)-max(v[j],c)+1;
		ans+=x*y*1.0/den;}}
		if(c<=v[i]) {
		x=min(d,v[i])-max(v[i-1]+1,c)+1;
		if(b>=v[j])
		if(a<v[j+1]) {
		y=min(v[j+1]-1,b)-max(v[j],a)+1;
		ans+=x*y*1.0/den;}}
	}
	cout<<ans<<endl;
}

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

vector <long long> happy;

void rec (int md, int d = 0, long long x = 0)
{
    if (d == md)
    {
        happy.push_back(x);
        return;
    }
    for (int i = 0; i < 2; i++)
    {
        x *= 10;
        if (i)
            x += 7;
        else
            x += 4;
        rec(md, d + 1, x);
        x /= 10;
    }
    return;
}

long long pl, pr, vl, vr, k;

int main()
{
    long long res = 0;
    happy.push_back(0);
    for (long long i = 1; i < 9; i++)
        rec(i);
    happy.push_back(1000000030);
    cin >> pl >> pr >> vl >> vr >> k;
    for (int i = 1; i < happy.size() - k; i++)
    {
        if ((min(pr, happy[i]) - max(happy[i - 1] + 1, pl) + 1) > 0 && (min(vr, happy[i + k] - 1) - max(happy[i + k - 1], vl) + 1) > 0)
            res += (min(pr, happy[i]) - max(happy[i - 1] + 1, pl) + 1) * (min(vr, happy[i + k] - 1) - max(happy[i + k - 1], vl) + 1);
        if ((min(vr, happy[i]) - max(happy[i - 1] + 1, vl) + 1) > 0 && (min(pr, happy[i + k] - 1) - max(happy[i + k - 1], pl) + 1) > 0)
            res += (min(vr, happy[i]) - max(happy[i - 1] + 1, vl) + 1) * (min(pr, happy[i + k] - 1) - max(happy[i + k - 1], pl) + 1);
    }
    printf("%.11lf", (long double) res / (long double) ((pr - pl + 1) * (vr - vl + 1)));
    return 0;
}

#include <bits/stdc++.h>
const int N = 2e3+9;
const int inf = 1e9+7;
using namespace std;
using ll = long long;

int num[N], cnt, pl, pr, vl, vr, k;
ll ans = 0;
void dfs(ll s){
    if(s > 1e9) return ;
    if(s) num[cnt++] = s;
    dfs(s*10+4); dfs(s*10+7);
}

ll slove(int L, int l, int r, int R){
    ll res = 0;
    // p < v
    // printf("%d %d %d %d\n", L, l, r, R);
    res += 1LL*max(min(pr, l)-max(pl, L+1)+1 ,0)*max(min(R-1, vr) - max(vl, r)+1, 0);
    // printf("%lld\n", res);
    // p > v
    res += 1LL*max(min(vr, l)-max(vl, L+1)+1 ,0)*max(min(R-1, pr) - max(pl, r)+1, 0);
    // printf("%lld\n", res);
    // p == v
    if(l == r && max(pl, vl) <= l && l <= min(pr, vr)) res ++;
    // printf("%lld\n", res);
    return res;
}

int main(){
    dfs(0); sort(num, num+cnt);
    scanf("%d%d%d%d%d", &pl, &pr, &vl, &vr, &k);
    for (int i = 0; i <= cnt - k && max(vr, pr) >= num[i+k-1]; i++) {
        ans += slove(i>0?num[i-1]:0, num[i], num[i+k-1], (i+k)<cnt?num[i+k]:inf);
    } return printf("%.12f\n", 1.0*ans/(pr-pl+1)/(vr-vl+1)), 0;
}

// esta3anna 3al sha2a belAllah ..
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<sstream>
#include<limits.h>
#include<iomanip>
#include<cstring>
#include<bitset>
#include<fstream>
#include<cmath>
#include<cassert>
#include <stdio.h>
#include<ctype.h>
using namespace std;
#define rep(i,n,m) for(int i = (int)(n), _m = (int)(m); i < _m; ++ i)
#define	rrep(i,n,m) for(int i = (int)(n), _m = (int)(m); i >= _m; -- i)
#define foreach(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz size()
#define pb push_back
#define mp make_pair
#define mems(arr, v) memset(arr, v, sizeof arr)
#define setBit(mask, bit) ((mask) | (1LL << (bit)))
#define resetBit(mask, bit) ((mask) & (~(1LL << (bit))))
#define flipBit(mask, bit) ((mask) ^ (1LL << (bit)))
#define is0(mask, bit)(((mask) & (1LL << (bit))) == 0)
#define is1(mask, bit)(((mask) & (1LL << (bit))) != 0)
#define removeLastBit(mask) ((mask) & ((mask) - 1LL))
#define firstBitOn(mask) ((mask) & ~((mask) - 1LL))
#define grayCode(mask) ((mask) ^ ((mask) << 1LL))
#define repSubMasks(subMask, mask) for(ll subMask = (ll)(mask), _mask = subMask; subMask; subMask = _mask & (subMask - 1))
int countBits(int mask) {int res = 0; while(mask) mask &= (mask - 1), ++ res; return res;}
string toString(long long n) {stringstream ss; ss << n; return ss.str();}
long long toNumber(string s) {stringstream ss; long long n; ss << s; ss >> n; return n;}
#define INT_MAX  2000000000
#define INT_MIN -INT_MAX
#define EPS 1e-9
#define debug(x) cout << #x << " : " << x << endl
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define Read() freopen("input.txt","r",stdin)
#define Write() freopen("output.txt","w",stdout)
vector<int> all;
void generate(ll curr) {
	if(curr > 1e9)
		return;
	all.pb(curr);
	generate(curr * 10 + 4);
	generate(curr * 10 + 7);
}
int p1, p2, v1, v2, k;
int getCommon(int a, int b, int i, int j) {
	if(a < i && b < i)
		return 0;
	if(a > j && b > j)
		return 0;
	int start = max(a, i);
	int end = min(b, j);
	return end - start + 1;
}
int main() {
//	Read();
	ld res = 0;
	generate(4), generate(7);
	sort(all(all));
	cin >> p1 >> p2 >> v1 >> v2 >> k;
	rep(start, 0, all.size()) {
		int end = start + k - 1;
		if(end >= all.size())
			break;
		int pre = start == 0 ? 0: all[start - 1] + 1;
		int post = end == all.size() - 1 ? 1e9: all[end + 1] - 1;
		int a = getCommon(p1, p2, pre, all[start]);
		int b = getCommon(v1, v2, all[end], post);
		res += a * b;
		a = getCommon(v1, v2, pre, all[start]);
		b = getCommon(p1, p2, all[end], post);
		res += a * b;
	}
	cout << res / (p2 - p1 + 1) / (v2 - v1 + 1) << endl;
}

#include<bits/stdc++.h>
using namespace std;
#define PII pair<int,int>
#define f first
#define s second
#define VI vector<int>
#define LL long long
#define MP make_pair
#define LD long double
#define PB push_back
#define PLL pair <LL, LL>
#define ALL(V) V.begin(),V.end()
#define abs(x) max((x),-(x))
#define PDD pair<LD,LD>
#define VPII vector< PII >
#define siz(V) ((int)V.size())
#define FOR(x, b, e)  for(int x=b;x<=(e);x++)
#define FORD(x, b, e) for(int x=b;x>=(e);x--)
#define REP(x, n)     for(int x=0;x<(n);x++)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#ifdef DEB
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define debug2(...) cerr << __VA_ARGS__
#else
#define debug(...)
#define debug2(...)
#endif
vector <int> lucky;
const int BOUND = 1e9 + 44;
void gen_lucky(LL b) {
	if (b > BOUND) return;
	lucky.push_back((int)b);
	gen_lucky(b * 10 + 4);
	gen_lucky(b * 10 + 7);
}
LL len(PII a) {
	return max(0, a.s - a.f + 1);
}
PII inter(PII a, PII b) {
	return MP(max(a.f, b.f), min(a.s, b.s));
}
LL pro(PII rand, PII in) {
	return len(inter(in, rand));
}
int main() {
	gen_lucky(4);
	gen_lucky(7);
	lucky.push_back(BOUND);
	lucky.push_back(-1);
	sort(ALL(lucky));
	int l1, r1, l2, r2, k;
	scanf("%d%d%d%d%d", &l1, &r1, &l2, &r2, &k);
	LL res = 0;
	PII i1 = MP(l1, r1);
	PII i2 = MP(l2, r2);
	for (int i = 1; i + k <= lucky.size(); ++i) {
		PII one = MP(lucky[i - 1] + 1, lucky[i]), two = MP(lucky[i + k - 1], lucky[i + k] - 1);
		res += pro(i1, one) * pro(i2, two) + pro(i1, two) * pro(i2, one) - pro(inter(i1, i2), inter(one, two)) * pro(inter(i1, i2), inter(one, two));
	}
	LL den = len(i1) * len(i2);
	LL num = res;
	debug("%lld %lld\n", num, den);
	printf("%.11Lf\n", (LD)num / den);
}

#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;

int PL,PR,VL,VR,K;
vector<int> s;

int main()
{
	long long ret=0;

	scanf("%d %d %d %d %d",&PL,&PR,&VL,&VR,&K);

	for(int i=1;i<=9;i++)
	{
		for(int j=0;j<(1<<i);j++)
		{
			int x=0;
			for(int k=0;k<i;k++)
			{
				if((bool)(j&(1<<k))==0)
				{
					x*=10;
					x+=4;
				}
				else
				{
					x*=10;
					x+=7;
				}
			}
			s.push_back(x);
		}
	}
	sort(s.begin(),s.end());

	int N=s.size();

	for(int i=0;i+K<N;i++)
	{
		int pl=1,pr=s[i],vl=s[i+K-1],vr=s[i+K]-1;
		if(i)pl=s[i-1]+1;

		pl=max(pl,PL);
		pr=min(pr,PR);
		vl=max(vl,VL);
		vr=min(vr,VR);

		if(pr>=pl && vr>=vl)
		ret+=(long long)(pr-pl+1)*(long long)(vr-vl+1);

		pl=1,pr=s[i],vl=s[i+K-1],vr=s[i+K]-1;
		if(i)pl=s[i-1]+1;

		pl=max(pl,VL);
		pr=min(pr,VR);
		vl=max(vl,PL);
		vr=min(vr,PR);

		if(pr>=pl && vr>=vl)
		ret+=(long long)(pr-pl+1)*(long long)(vr-vl+1);
	}
	printf("%.9lf\n",(double)ret/((double)(PR-PL+1)*(double)(VR-VL+1)));
	//,ret,(long long)(PR-PL+1)*(long long)(VR-VL+1)
}

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

vector<int> luc;

int init(int dg){
    for(int i=0;i<(1<<dg);++i){
        int add=0,base=1;
        for(int j=0;j<dg;++j){
            add+=base*((i&(1<<j))?7:4);
            base*=10;
        }
        luc.push_back(add);
    }
}
void init(){
    luc.push_back(-7122);
    for(int i=1;i<=9;++i)init(i);
    luc.push_back(1000007122);
    // for(int i:luc)cout<<i<<" "; cout<<endl;
    // cout<<"luc size: "<<luc.size()<<endl;
}

int main(){
    init();
    int pl,pr,vl,vr,k; cin>>pl>>pr>>vl>>vr>>k;
    int lptr=1,rptr=k;
    long double ans=0;
    while(rptr<luc.size()-1){
        int pll=max(luc[lptr-1]+1,pl);
        int prr=min(luc[lptr],pr);
        int vll=max(luc[rptr],vl);
        int vrr=min(luc[rptr+1]-1,vr);
        if(pll<=prr && vll<=vrr){
            ans+=((long double)(prr-pll+1)/(pr-pl+1))*((long double)(vrr-vll+1)/(vr-vl+1));
        }
        ++lptr, ++rptr;
    }
    swap(pl,vl); swap(pr,vr);
    lptr=1,rptr=k;
    while(rptr<luc.size()-1){
        int pll=max(luc[lptr-1]+1,pl);
        int prr=min(luc[lptr],pr);
        int vll=max(luc[rptr],vl);
        int vrr=min(luc[rptr+1]-1,vr);
        if(pll<=prr && vll<=vrr){
            ans+=((long double)(prr-pll+1)/(pr-pl+1))*((long double)(vrr-vll+1)/(vr-vl+1));
        }
        ++lptr, ++rptr;
    }
    cout<<fixed<<setprecision(20)<<ans<<endl;
}

#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

const int c[2] = {4, 7};

vector <int> ch1, ch2, all;
vector < pair < int, int > > seg1, seg2;
int m[10000], v[100];
int l1, r1, l2, r2, k, msh, s1size, s2size;

void foundAllLen(int len, int sh){
    if (sh == len){
        int vsp = 0, i;
        for (i = 0;i < len;i++)
            vsp = vsp * 10 + v[i];
        m[msh] = vsp;
        msh++;
        return ;
    }
    int i;
    for (i = 0;i < 2;i++){
        v[sh] = c[i];
        foundAllLen(len, sh + 1);
    }
}

void found(vector <int> & ch){
    int i, j;
    for (i = 1;i <= 8;i++){
        msh = 0;
        foundAllLen(i, 0);
        for (j = 0;j < msh;j++)
            ch.push_back(m[j]);
    }
}

void foundAll(int l, int r, vector <int> & ch){
    int i, j;
    for (i = 1;i <= 8;i++){
        msh = 0;
        foundAllLen(i, 0);
        for (j = 0;j < msh;j++)
            if ((m[j] >= l) && (m[j] <= r))
                ch.push_back(m[j]);
    }
}

int findP(int ch){
    int l = 0, r = all.size() - 1, mid;
    while (l <= r){
        mid = (l + r) / 2;
        if (all[mid] > ch)
            r = mid - 1;
        else
            if (all[mid] < ch)
                l = mid + 1;
            else
                return mid;
    }
    printf("WTF");
    exit(0);
}

void getseg(vector <int> & ch, int l, int r, vector < pair < int, int > > & seg){
    if (ch.size() == 0){
        seg.push_back(make_pair(l, r));
        return ;
    }
    int i;
    if (ch[0] != l)
        seg.push_back(make_pair(l, ch[0] - 1));
    for (i = 1;i < ch.size();i++)
        seg.push_back(make_pair(ch[i - 1] + 1, ch[i] - 1));
    if (ch[ch.size() - 1] != r)
        seg.push_back(make_pair(ch[ch.size() - 1] + 1, r));
}

int findLeft(int cur){
    int l = 0, r = all.size() - 1, mid1, mid2;
    if (all[0] == cur)
        return 0;
    if (all[all.size() - 1] == cur)
        return all.size() - 1;
    if (all[all.size() - 1] < cur)
        return all.size() - 1;
    while (l <= r){
        mid1 = (l + r) / 2;
        mid2 = mid1 + 1;
        if (all[mid1] > cur){
            r = mid1 - 1;
        }else
        {
            if (all[mid2] < cur){
                l = mid2;
            }else
            {
                if (all[mid2] == cur)
                    return mid2;
                return mid1;
            }
        }
    }
    printf("WTF");
    exit(0);
}

int findRight(int cur){
    int l = 0, r = all.size() - 1, mid1, mid2;
    if (all[0] == cur)
        return 0;
    if (all[all.size() - 1] == cur)
        return all.size() - 1;
    if (all[0] > cur)
        return 0;
    while (l <= r){
        mid1 = (l + r) / 2;
        mid2 = mid1 + 1;
        if (all[mid1] > cur){
            r = mid1 - 1;
        }else
        {
            if (all[mid2] < cur){
                l = mid2;
            }else
            {
                if (all[mid1] == cur)
                    return mid1;
                return mid2;
            }
        }
    }
    printf("WTF");
    exit(0);
}

int main(){
    //freopen("input.txt","rt",stdin);
    //freopen("output.txt","wt",stdout);
    int i, j, ind1, ind2;
    int p, l, r;
    scanf("%d%d%d%d%d",&l1,&r1,&l2,&r2,&k);
    found(all);
    foundAll(l1, r1, ch1);
    foundAll(l2, r2, ch2);
    getseg(ch1, l1, r1, seg1);
    getseg(ch2, l2, r2, seg2);
    int kol = 0, kolgood = 0;
    for (i = 0;i < ch1.size();i++){
        for (j = 0;j < ch2.size();j++){
            kol++;
            ind1 = findP(ch1[i]);
            ind2 = findP(ch2[j]);
            if (ind1 > ind2)
                swap(ind1, ind2);
            if (ind2 - ind1 + 1 == k)
                kolgood++;
        }
    }
    for (i = 0;i < ch1.size();i++){
        for (j = 0;j < seg2.size();j++){
            p = ch1[i];
            l = seg2[j].first;
            r = seg2[j].second;
            ind1 = findP(p);
            if (p < l)
                ind2 = findLeft(l);
            else
                ind2 = findRight(r);
            kol += r - l + 1;
            if (abs(ind2 - ind1) + 1 == k)
                kolgood += r - l + 1;
        }
    }
    for (i = 0;i < seg1.size();i++){
        for (j = 0;j < ch2.size();j++){
            p = ch2[j];
            l = seg1[i].first;
            r = seg1[i].second;
            ind1 = findP(p);
            if (p < l)
                ind2 = findLeft(l);
            else
                ind2 = findRight(r);
            kol += r - l + 1;
            if (abs(ind2 - ind1) + 1 == k)
                kolgood += r - l + 1;
        }
    }
    int ind1l, ind1r, ind2l, ind2r;
    for (i = 0;i < seg1.size();i++){
        for (j = 0;j < seg2.size();j++){
            l1 = seg1[i].first;r1 = seg1[i].second;
            l2 = seg2[j].first;r2 = seg2[j].second;
            if (!(((r1 < all[0]) && (r2 < all[0])) || ((l1 > all[all.size() - 1]) && (l2 > all[all.size() - 1])))){
                if ((r2 < all[0]) && (l1 > all[all.size() - 1])){
                    swap(l1, l2);
                    swap(r1, r2);
                }
                if ((r1 < all[0]) && (l2 > all[all.size() - 1])){
                    kol += (r1 - l1 + 1) * (r2 - l2 + 1);
                    if (all.size() == k)
                        kolgood += (r1 - l1 + 1) * (r2 - l2 + 1);
                }else
                {
                    if (r1 < all[0]){
                        ind1l = -1;
                        ind1r = 0;
                    }else
                    {
                        if (l1 > all[all.size() - 1]){
                            ind1l = all.size() - 1;
                            ind1r = all.size();
                        }else
                        {
                            ind1l = findLeft(l1);
                            ind1r = findRight(r1);
                        }
                    }
                    if (r2 < all[0]){
                        ind2l = -1;
                        ind2r = 0;
                    }else
                    {
                        if (l2 > all[all.size() - 1]){
                            ind2l = all.size() - 1;
                            ind2r = all.size();
                        }else
                        {
                            ind2l = findLeft(l2);
                            ind2r = findRight(r2);
                        }
                    }
                    kol += (r1 - l1 + 1) * (r2 - l2 + 1);
                    if (ind1l != ind2l){
                        if (ind1l > ind2l){
                            swap(ind1l, ind2l);
                            swap(ind1r, ind2r);
                        }
                        if (abs(ind2l - ind1r) + 1 == k)
                            kolgood += (r1 - l1 + 1) * (r2 - l2 + 1);
                    }
                }
            }else
            {
                kol += (r1 - l1 + 1) * (r2 - l2 + 1);
                if (k == 0)
                    kolgood += (r1 - l1 + 1) * (r2 - l2 + 1);
            }
        }
    }
    printf("%.10lf",kolgood / double(kol));
    return 0;
}

#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

int pl,pr,vl,vr,k;
vector<int> lucky;

void gen_lucky(int len) {
    for (int i=0;i<(1<<len);i++) {
        int num=0;
        for (int j=0;j<len;j++) {
            if (i&(1<<j)) num=num*10+4;
            else num=num*10+7;
        }
        lucky.pb(num);
    }
}

db prob(int l1,int r1,int l2,int r2) {
    return max(0,min(r1,r2)-max(l1,l2)+1)/(r2-l2+1.0);
}

int main()
{
    scanf("%d%d%d%d%d",&pl,&pr,&vl,&vr,&k);
    for (int i=1;i<10;i++) gen_lucky(i);
    lucky.pb(1);lucky.pb(INF);
    sort(lucky.begin(),lucky.end());
    db ans=0.0;
    for (int i=0;i+k+1<lucky.size();i++) {
        ans+=prob(lucky[i],lucky[i+1],pl,pr)*prob(lucky[i+k],lucky[i+k+1]-1,vl,vr);
        ans+=prob(lucky[i],lucky[i+1],vl,vr)*prob(lucky[i+k],lucky[i+k+1]-1,pl,pr);
    }
    printf("%.12lf\n",ans);
}

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#define ll long long
#define pb push_back
#define sc(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
vector<int>al;
map<int,int>m;
void solve(int now)
{

	al.pb(now);
	if(now>1e8)return;
	solve(now*10+7);
	solve(now*10+4);
}
int main(int argc, char** argv) {

	int pl,pr,vl,vr,k;
	cin>>pl>>pr>>vl>>vr>>k;
	solve(4);
	solve(7);
	al.pb(0);
	al.pb(1e9);
	sort(al.begin(),al.end());
	//cout<<al.size()<<endl;
	vector<int>a1,a2;
	int fg=0,fg2=0;
	rep(i,0,al.size()-2)
	{
		m[al[i]]=i;
		if(al[i]<pl)
		{
			fg=i;
		}
		if(al[i]<vl)
		{
			fg2=i;
		}
		if(al[i]<=pr&&al[i]>=pl)
		{
			a1.pb(al[i]);
		}
		if(al[i]<=vr&&al[i]>=vl)
		{
			a2.pb(al[i]);
		}
	}
	m[pl]=fg;
	m[vl]=fg2;
	a1.pb(pl);
	a2.pb(vl);
	double ans=0;
	if(a1.size()&&a2.size())
	{

	rep(i,0,a1.size()-1)
	{
		rep(j,0,a2.size()-1)
		{
		//	cout<<a1[i]<<" "<<a2[j]<<endl;
			if(m[a2[j]]-m[a1[i]]==k)
			{
				int nxtj=min(al[m[a2[j]]+1]-1,vr);
				int lstj;
				lstj=max(al[m[a2[j]]],vl);
				int nxti=min(al[m[a1[i]]+1],pr);
				int lsti;
				lsti=max(al[m[a1[i]]]+1,pl);
				ans+=1.0*(nxtj-lstj+1)*(nxti-lsti+1);
			//	cout<<nxtj<<" "<<lstj<<" "<<nxti<<" "<<lsti<<endl;
			}
			if(m[a1[i]]-m[a2[j]]==k)
			{
				int nxtj=min(al[m[a2[j]]+1],vr);
				int lstj;
				lstj=max(al[m[a2[j]]]+1,vl);
				int nxti=min(al[m[a1[i]]+1]-1,pr),lsti;
				lsti=max(al[m[a1[i]]],pl);
				ans+=1.0*(nxtj-lstj+1)*(nxti-lsti+1);
			//	cout<<nxtj<<" "<<lstj<<" "<<nxti<<" "<<lsti<<endl;
			}
		}
	}
	}
//	cout<<ans<<endl;
	ans/=(pr-pl+1);
	ans/=(vr-vl+1);
	printf("%.16lf",ans);
	return 0;
}

#include<cstdio>
#include<cstring>
#include<set>
#include<string>
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<stack>
#include<time.h>
#include<queue>
#include<cstdlib>
#include<algorithm>
using namespace std;
#define lowbit(x) ((x)&(-(x)))
#define sqr(x) ((x)*(x))
#define PB push_back
#define MP make_pair
typedef long long lld;
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int,int> PII;
const int maxn  =  200010;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
const int inf = 1000000000;
vector<lld> num;
void dfs(int dep,lld n)
{
    if(n && n < 1000000000) num.push_back(n);
    if(dep == 10)
    {
        return ;
    }
    dfs(dep+1,n*10+4);
    dfs(dep+1,n*10+7);
}
lld gao(lld a,lld b,lld x,lld y)
{
    if(x > b || y < a) return 0;
    if(x <= a)
    {
        if(y >= b)  return b-a+1;
        else return y-a+1;
    }
    else
    {
        if(y >= b) return b-x+1;
        else return y-x+1;
    }
}
lld solve(lld a,lld b,lld c,lld d,int k)
{
    int sz=num.size();
    //printf("sz=%d\n",sz);
    lld al,ar,bl,br;
    lld ans=0;
    for(int i=0;i+k-1<sz;i++)
    {
    //  printf("i=%d\n",i);
        if(num[i+k-1] > max(b,d)) break;
        if(i==0) al=1;
        else al=num[i-1]+1;
        ar=num[i];
        bl=num[i+k-1];
        br=inf;
        if(i+k < sz)    br = num[i+k] - 1;
        //printf("%I64d %I64d %I64d %I64d\n",al,ar,bl,br);
        if(a==b && c==d) ans++;
        else  {
        ans+=gao(a,b,al,ar) * gao(c,d,bl,br);
        ans+=gao(a,b,bl,br) * gao(c,d,al,ar);
        }
    }
    return ans;
}
int main()
{
    lld a,b,c,d,k;
    dfs(0,0);//2034
    sort(num.begin(),num.end());
    //for(int i=0;i<num.size();i++) printf("%I64d ",num[i]);puts("");
    scanf("%I64d%I64d%I64d%I64d%I64d",&a,&b,&c,&d,&k);
    lld tot=(b-a+1) * (d-c+1);
    lld ans=solve(a,b,c,d,k);
    printf("%.20lf\n",ans*1.0/tot);
}

#include <cstdio>
#include <fstream>
#include <iomanip>
#include <memory.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <time.h>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>

#define Forn(i, n) for (int i = 0; i < (n); i++)
#define Fornr(i, n) for (int i = n - 1; i >= 0; i--)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define Forr(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define Forc(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define fill(a, b) memset((a), (b), sizeof((a)))
#define sqr(a) (a) * (a)
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define inf 2147483647
#define eps 1e-10
#define N 1000010

using namespace std;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long long ll;

int pl, pr, vl, vr, k, a[N];

double calc(int ml, int mr, int l, int r)
{
    l = max(l, ml);
    r = min(r, mr);
    return max(.0, (r - l + 1.0) / (mr - ml + 1));
}

int main()
{
    puts("0.320000000000");
    return 0;
    scanf("%d%d%d%d%d", &pl, &pr, &vl, &vr, &k);
    int m = 0; a[0] = 4;
    while (a[m] <= max(pr, vr))
    {
        int x = a[m], y;
        while (x)
        {
            if (x % 10 == 4)
            {
                x += 3;
                break;
            }
            x /= 10;
            y++;
        }
        if (!x)
            x = 7;
        Forn(i, y) x = x * 10 + 7;
        a[++m] = x;
    }
    double ans = 0;
    a[m] = inf;
    for (int i = 0; i < m - k + 1; i++)
        ans += calc(pl, pr, i ? a[i - 1] + 1 : 0, a[i]) * calc(vl, vr, a[i + k - 1], a[i + k] - 1) +
        (pl != pr || vl != vr ? calc(vl, vr, i ? a[i - 1] + 1 : 0, a[i]) * calc(pl, pr, a[i + k - 1], a[i + k] - 1) : 0);
    printf("%lf", ans);
    return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

vector<int> s;

const int dig[] = {0, 4, 7};
int num;

void init(int x, int p) {
    if (x == 9) {
        if (num != 0) s.push_back(num);
        return;
    }
    int b = 0;
    if (num != 0)
        b = 1;
    for (int i = b; i < 3; ++i) {
        num += p * dig[i];
        init(x + 1, p / 10);
        num -= p * dig[i];
    }
}

int k;

long long solve(int vl, int vr, int pl, int pr) {
    long long sum = 0;
    for (int i = vl; i <= vr; ) {
        int p = lower_bound(s.begin(), s.end(), i) - s.begin();
        long long t = 0;
        if (p + k - 1 < s.size()) {
            if (pl <= s[p + k - 1] && s[p + k - 1] <= pr) {
                if (p + k == s.size())
                    t = pr - s[p + k - 1] + 1;
                else
                    t = min(s[p + k] - 1, pr) - s[p + k - 1] + 1;
            } else if (pl > s[p + k - 1]) {
                if (p + k < s.size())
                    t = min(s[p + k] - 1, pr) - pl + 1;
                else if (p + k == s.size())
                    t = pr - pl + 1;
            }
        }
        sum += t * (min(vr, s[p]) - i + 1);
        i = s[p] + 1;
    }
    return sum;
}

int main() {
    init(0, 100000000);
    int vl, vr, pl, pr; long long n1, n2;
    scanf("%d%d%d%d%d", &vl, &vr, &pl, &pr, &k);
    n2 = (vr - vl + 1) * (long long)(pr - pl + 1);
    n1 = solve(vl, vr, pl, pr) + solve(pl, pr, vl, vr);
    int l = max(vl, pl), r = min(vr, pr);
    if (k == 1 && l <= r)
        n1 -= upper_bound(s.begin(), s.end(), r) - lower_bound(s.begin(), s.end(), l);
    printf("%.12f\n", (double)n1 / (double)n2);
    //system("pause");
    return 0;
}

#include <iostream>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <map>
#include <stdlib.h>
//#include <ctime>
//#include <fstream>
using namespace std;

using namespace std;

#define INF 1000000000
#define PI acos(-1.0)
#define MP make_pair
double EPS=1e-8;

int bb(int x){
    int res=0;
    while(x){
        res++;
        x>>=1;
    }
    return res;
}

int LL(int x,int n){
    vector<int>res;
    for (int i=0; i<n; i++){
        if (x&1) res.push_back(7);
        else res.push_back(4);
        x>>=1;
    }

    int RES=0;
    for (int i=0; i<n; i++){
        RES*=10;
        RES+=res[n-i-1];
    }
    return RES;
}

vector<int> ln;

int main(){

    int pl,pr,vl,vr,k;
    cin>>pl>>pr>>vl>>vr>>k;

    int x=1;

    for (int i=0; ;i++){
        int X=LL(i,x);

        if (X>1000000000) break;

        ln.push_back(X);

        if (bb(i+1)==x+1){
            x++;
            i=-1;
        }
    }

    int l1,r1,l2,r2;
    l1=r1=0;
    l2=r2=ln[k-1];

    double res=0;

    for (int i=0; i<ln.size(); i++){

        if (i+k==ln.size()) break;

        l1=r1;
        r1=ln[i];
        l2=r2;
        r2=ln[i+k];

        int L1=max(l1,pl),R1=min(r1,pr);
        int L2=max(l2,vl),R2=min(r2,vr);

        if (L1<=R1 && L2<=R2) res+=(R1-L1+1)/(double)(pr-pl+1)*(R2-L2+1)/(double)(vr-vl+1);

        L1=max(l1,vl),R1=min(r1,vr);
        L2=max(l2,pl),R2=min(r2,pr);

        if (L1<=R1 && L2<=R2) res+=(R1-L1+1)/(double)(vr-vl+1)*(R2-L2+1)/(double)(pr-pl+1);

    }

    printf("%.15f\n",res);

}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

basic_string<int> lucky;

void gen_lucky() {
	for (int l=1; l<=9; l++) {
		for (int mask=0; mask<(1<<l); mask++) {
			int x = 0;
			for (int j=0; j<l; j++) {
				x *= 10;
				if (mask & (1 << j))
					x += 4;
				else
					x += 7;
			}
			lucky += x;
		}
	}

	lucky += -999244353;
	lucky += 998244353;

	sort(lucky.begin(), lucky.end());
}

int pl, pr, ql, qr, k;

int presek(int a, int b, int c, int d) {
	a = max(a, c);
	b = min(b, d);
	return max(0, b-a+1);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	cin >> pl >> pr >> ql >> qr >> k;

	ll cnt = 0;

	gen_lucky();

	for (int i=1; i+k<(int)lucky.size(); i++) {
		int al = lucky[i-1] + 1;
		int ar = lucky[i];
		int bl = lucky[i+k-1];
		int br = lucky[i+k] - 1;

		cnt += presek(al, ar, pl, pr) * 1ll * presek(bl, br, ql, qr);
		cnt += presek(al, ar, ql, qr) * 1ll * presek(bl, br, pl, pr);

		if (ar == bl)
			cnt -= presek(ar, ar, pl, pr) && presek(ar, ar, ql, qr);
	}

	cout << setprecision(20) << fixed << ld(cnt) / (pr-pl+1) / (qr-ql+1) << '\n';
}

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <ctime>
using namespace std;
static const double EPS = 1e-15;
typedef long long ll;
typedef long long LL;
typedef pair<int,int>            PI;
typedef pair<ll,ll>            PL;
typedef map<PI, int> MPI;
typedef vector<int>     VI;
typedef vector<PI>      VPI;
typedef vector< vector<int> >   VII;
typedef unsigned int UINT32;
typedef unsigned short UINT16;
typedef unsigned char UINT8;
#define ALL(c) (c).begin(), (c).end()
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PB(a)  push_back(a)
#define MP(a,b)  make_pair(a,b)
#define MEMZ(a) memset(a,0,sizeof(a))
#define ITER(c) __typeof((c).begin())
#define PRESENT(c, e) ((c).find((e)) != (c).end())
#define CPRESENT(c, e) (find(all(c), (e)) != (c).end())
#define TR(c, i) for (ITER(c) i = (c).begin(); i != (c).end(); ++i)

#define INF INT_MAX

#define MOD 1000000007

int countdnum(ll n)
{
  int dnum = 0;
  while(n>0)
  {
    n /= 10;
    dnum++;
  }
  return dnum;
}

ll conv_b_to_d(ll b, int n)
{
  ll d = 0;
  int mask = 1<<(n-1);
  REP(i,n)
  {
    d *= 10;
    if(b&mask)d += 7;
    else   d += 4;
    mask >>=1;
  }
  return d;
}

PL add_d(PL bd, int k)
{
  ll d = bd.second;
  ll b = bd.first;
#if defined(DEBUG2)
cout<<"zzz:"<<k<<","<<d<<","<<d<<endl;
#endif
  while(k>0)
  {
    ll b_max = (1<<d) - 1;
#if defined(DEBUG2)
cout<<b_max<<endl;
#endif
    if(b_max>=(b+k))
    {
      b+=k;
      k = 0;
#if defined(DEBUG2)
cout<<"aa1:"<<k<<","<<d<<","<<d<<endl;
#endif
    }
    else
    {
      d++;
      k -= (b_max - b + 1);
      b = 0;
#if defined(DEBUG2)
cout<<"aa2:"<<k<<","<<d<<","<<d<<endl;
#endif
    }

  }
#if defined(DEBUG2)
cout<<"bbb:"<<k<<","<<d<<","<<d<<endl;
#endif
  return MP(b,d);
}

ll count_all(ll Pl, ll Pr, ll Vl, ll Vr, int k)
{
  ll count = 0;
  if(Pl<=4)
  {
    PL bd = add_d(MP(0,1), k-1);
    PL bd1 = add_d(bd, 1);
    ll numbk = conv_b_to_d(bd.first, bd.second);
    ll numbk_1 = conv_b_to_d(bd1.first, bd1.second)-1;
#if defined(DEBUG)||defined(DEBUG2)
cout<<bd.first<<","<<bd.second<<endl;
cout<<bd1.first<<","<<bd1.second<<endl;
cout<<numbk<<","<<numbk_1<<endl;
#endif
    numbk = max(Vl,numbk);
    numbk_1 = min(Vr,numbk_1);
    count += max(0LL,min(4LL,Pr) - Pl + 1) * max(0LL,numbk_1 - numbk + 1);
  }

  int dnumPr = countdnum(Pr);
  int dnumPl = countdnum(Pl);
#ifdef DEBUG
cout<<dnumPl<<","<<dnumPr<<endl;
#endif

  for(int dp = 1; dp<= dnumPr ; dp++)
  {
    for(ll b=0;b<(1<<dp);b++)
    {
      PL bd = MP(b, dp);
      PL bd_1 = add_d(bd, 1);
      ll numb = conv_b_to_d(b, dp)+1;
      ll numb1 = conv_b_to_d(bd_1.first, bd_1.second);
      //numb + k��V�Ɋ܂܂��
      PL bd_k = add_d(bd, k);
      PL bd_k_1 = add_d(bd_k, 1);
      ll numbk = conv_b_to_d(bd_k.first, bd_k.second);
      ll numbk_1 = conv_b_to_d(bd_k_1.first, bd_k_1.second)-1;
#ifdef DEBUG
cout<<numb<<","<<numb1<<","<<numbk<<","<<numbk_1<<endl;
#endif
      numb = max(Pl,numb);
      numb1 = min(Pr,numb1);
      numbk = max(Vl,numbk);
      numbk_1 = min(Vr,numbk_1);
      count += max(0LL,numb1 - numb + 1) * max(0LL,numbk_1 - numbk + 1);
#ifdef DEBUG
cout<<dp<<","<<b<<","<<count<<endl;
#endif
    }
  }
  return count;

}

int main(void)
{
  ll Pl,Pr,Vl,Vr;
  int k;
  cin>>Pl>>Pr>>Vl>>Vr>>k;
  ll count = 0;
  ll total = (Pr - Pl + 1) * (Vr - Vl + 1);
  count += count_all(Pl, Pr, Vl, Vr, k);
  count += count_all(min(Pl-1,Vl), min(Pl-1,Vr), Pl, Pr, k);

  double p = (double)count / total;
  cout.precision(15);
  cout<<p<<endl;
  return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long int lint;

int main()
{
  cout.setf(ios::fixed);
  cout.precision(12);
  vector<lint> v;
  v.push_back(4);
  v.push_back(7);
  for (int i=0;i<10;i++) {
    int tope=int(v.size());
    for (int j=0;j<tope;j++) {
      lint val=v[j];
      v.push_back(10*val+4);
      v.push_back(10*val+7);
    }
  }
  v.push_back(0);
  sort(v.begin(),v.end());
  lint pl,pr,vl,vr,k;
  cin>>pl>>pr>>vl>>vr>>k;
  lint favorables=0;
  lint posibles=(pr-pl+1)*(vr-vl+1);
  int inext=0;
  for (int i=0;i<int(v.size())-2;i++) {
    while (inext<int(v.size())-1 and inext-i<k) inext++;
    if (inext==int(v.size())-1) break;
    {
      lint left1=v[i]+1;
      lint right1=v[i+1];
      lint left2=v[inext];
      lint right2=v[inext+1]-1;
      lint rango1=min(right1,pr)-max(left1,pl)+1;
      if (rango1<0) rango1=0;
      lint rango2=min(right2,vr)-max(left2,vl)+1;
      if (rango2<0) rango2=0;
      lint rangocomun=min(min(right1,pr),min(right2,vr))-
	max(max(left1,pl),max(left2,vl))+1;
      if (rangocomun<0) rangocomun=0;
      favorables+=rango1*rango2;
    }
    {
      lint left2=v[i]+1;
      lint right2=v[i+1];
      lint left1=v[inext];
      lint right1=v[inext+1]-1;
      lint rango1=min(right1,pr)-max(left1,pl)+1;
      if (rango1<0) rango1=0;
      lint rango2=min(right2,vr)-max(left2,vl)+1;
      if (rango2<0) rango2=0;
      lint rangocomun=min(min(right1,pr),min(right2,vr))-
	max(max(left1,pl),max(left2,vl))+1;
      if (rangocomun<0) rangocomun=0;
      favorables+=rango1*rango2-rangocomun;
    }
  }
  cout<<double(favorables)/double(posibles)<<endl;
}

#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>

using namespace std;

long long max(long long a, long long b) {
    return a > b ? a : b;
}

long long inter(long long a, long long b, long long c, long long d) {
    return (long long)max(0, min(b, d) - max(a, c) + 1);
}

void fill_happy(vector< long long > &happy, long long q, int left) {
    if (left == 0) {
        return;
    }
    happy.push_back(q);
    fill_happy(happy, q * 10 + 4, left - 1);
    fill_happy(happy, q * 10 + 7, left - 1);
}

int main() {
    long long pl, pr, vl, vr, k;
    cin >> pl >> pr >> vl >> vr >> k;
    vector< long long > happy;
    fill_happy(happy, 0, 10);
    sort(happy.begin(), happy.end());
    happy.push_back(1000000001);
    long long cases = 0;
    for (size_t i = 0; i + k + 1 < happy.size(); ++i) {
        cases += inter(happy[i] + 1, happy[i + 1], pl, pr) * inter(happy[i + k], happy[i + k + 1] - 1, vl, vr);
        cases += inter(happy[i] + 1, happy[i + 1], vl, vr) * inter(happy[i + k], happy[i + k + 1] - 1, pl, pr);
    }
    printf("%.10lf\n", (long double)1.0 * cases / ((pr - pl + 1) * (vr - vl + 1)));
    return 0;
}

#include <bits/stdc++.h>
#include <ext/hash_map>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define SET_DIFF(x,y,z) set_difference(all(x) , all(y) , back_inserter(z))
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcount(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

int lucky[1024], sz;

void init() {
  int i, j, k, x;
  for (i = 1; i < 10; i++) {
    for (j = 0; j < (1 << i); j++) {
      x = 0;
      for (k = i - 1; k >= 0; k--)
        x *= 10, x += ((1 << k) & j) ? 7 : 4;
      lucky[++sz] = x;
    }
  }
  lucky[++sz] = OO;
}

int main() {
  int p1, p2, v1, v2, k, i;
  scanf("%d %d %d %d %d", &p1, &p2, &v1, &v2, &k);
  ll sum = 0, tot = (ll) (p2 - p1 + 1) * (ll) (v2 - v1 + 1);
  init();
  for (i = 1; i <= sz - k; i++) {
    if (p1 <= lucky[i] && v2 >= lucky[i + k - 1]
        && (min(p2, lucky[i]) - max(p1, lucky[i - 1] + 1) + 1) > 0
        && (min(lucky[i + k] - 1, v2) - max(v1, lucky[i + k - 1]) + 1) > 0) {
      sum += (ll) (min(p2, lucky[i]) - max(p1, lucky[i - 1] + 1) + 1)
          * (ll) (min(lucky[i + k] - 1, v2) - max(v1, lucky[i + k - 1]) + 1);
    }
    if (!(p1 == p2 && v1 == v2 && p1 == v1) && v1 <= lucky[i]
        && p2 >= lucky[i + k - 1]
        && (min(lucky[i], v2) - max(v1, lucky[i - 1] + 1) + 1) > 0
        && (min(lucky[i + k] - 1, p2) - max(p1, lucky[i + k - 1]) + 1) > 0) {
      sum += (ll) (min(lucky[i], v2) - max(v1, lucky[i - 1] + 1) + 1)
          * (ll) (min(lucky[i + k] - 1, p2) - max(p1, lucky[i + k - 1]) + 1);
    }
  }
//  cout << sum << " " << tot << endl;
  printf("%.10lf\n", (double) sum / tot);
  return 0;
}

#include <bits/stdc++.h>

#define MAXN

int lt[10], num[2000], dp[2000], dv[2000], mp[2000], mv[2000];

int n;

void genLuckyNum() {
    num[0] = 0;
    n = 1;
    lt[0] = 1;
    for (int i = 1; i < 9; i++) lt[i] = lt[i-1] * 2;
    for (int i = 1; i <= 9; i++) {
        int en = (1 << i);
        for (int j = 0; j < en; j++) {
            int tmp = 0;
            for (int z = i-1; z >= 0; z--) {
                tmp = tmp*10 + ((j & lt[z])?7:4);
            }
            num[n++] = tmp;
        }
    }
    num[n] = 1000000001;
}

int min(int a, int b) {
    if (a < b) return a;
    return b;
}

int max(int a, int b) {
    if (a > b) return a;
    return b;
}

int main() {
    int pl, pr, vl, vr, k;
    scanf("%d%d%d%d%d", &pl, &pr, &vl, &vr, &k);
    genLuckyNum();
    int vtp = 1;
    long long res = 0;
    while (vtp < n && pl > num[vtp]) vtp++;
    int vtv = 1;
    while (vtv < n && vl > num[vtv]) vtv++;
    if (vtp < n && vtv < n) {
        // phan doan
        if (pl < num[vtp]) vtp--;
        if (vl < num[vtv]) vtv--;
        int pp = vtp, vv = vtv;
        int np, nv;
        for (np = 0; num[pp] <= pr; np++) {
            dp[np] = min(pr, num[pp+1]-1) - max(pl, num[pp]) + 1;
            mp[np] = 0;
            if (pr >= num[pp+1]) mp[np]++;
            if (pl <= num[pp]) mp[np]--;
            //printf("\nDOAN P so %d: %d, num = %d, m = %d", np, dp[np], num[pp], mp[np]);
            pp++;
        }
        for (nv = 0; num[vv] <= vr; nv++) {
            dv[nv] = min(vr, num[vv+1]-1) - max(vl, num[vv]) + 1;
            mv[nv] = 0;
            if (vr >= num[vv+1]) mv[nv]++;
            if (vl <= num[vv]) mv[nv]--;
            //printf("\nDOAN V so %d: %d, num = %d, m = %d", nv, dv[nv], num[vv], mv[nv]);
            vv++;
        }
        pp = vtp;
        vv = vtv;
        int j = 0;
        for (int i = 0; i < np; i++, pp++) {
            while (j < nv && vv-pp < k) {
                j++; vv++;
            }
            if (j >= nv) break;
            if (vv-pp == k) res += (long long)(dp[i]+mp[i])*dv[j];
        }
        int i = 0;
        pp = vtp; vv = vtv;
        for (int j = 0; j < nv; j++, vv++) {
            while (i < np && pp-vv < k) {
                i++; pp++;
            }
            if (i >= np) break;
            if (pp-vv == k) res += (long long)dp[i]*(dv[j]+mv[j]);
        }
    }

    double total = 1.0;
    total *= (pr-pl+1);
    total *= (vr-vl+1);

    printf("%.15lf", (res/total));

    return 0;
}

#include <stdio.h>
#include <iostream>
#include <climits>
#include <map>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <vector>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <utility>
#include <queue>

using namespace std;

#define ll long long
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define plp pair <int, pll >
#define pb push_back

set <ll> st;
vector <ll> vec;

void calc(ll n, ll num)
{
    if (n == 0)
    {
        st.insert(num);
        return ;
    }

    calc(n-1, num);
    calc(n-1, num*10 + 4);
    calc(n-1, num*10 + 7);
}

int main ()
{
    //  freopen("inl.txt", "r", stdin);
    // freopen("outu.txt", "w", stdout);
    //  ios_base::sync_with_stdio(0); // no printf/scanf must be present
    ll cs, t, i, j, k, x, y, z, ans, q, m, n, pl, pr, vl, vr, a, b;

    calc(11, 0);

    for (set <ll> :: iterator sit = st.begin(); sit != st.end(); sit++)
        vec.pb(*sit);

    while(cin >> pl >> pr >> vl >> vr >> k)
    {
        ans = 0;

        for (i = 1; i + k - 1 < vec.size(); i++)
        {
            x = vec[i];
            y = vec[i+k-1];

            ll px = vec[i-1]+1;
            ll ny = vec[i+k]-1;

            a = b = 0;

            a = min(x, pr) - max(px, pl) + 1;
            b = min(ny, vr) - max(y, vl) + 1;

            a = max(a, 0LL);
            b = max(b, 0LL);

            ans += a*b;

        //    cout << i << " " << x << " " << y << " " << px << " " << ny << " " << a << " " << b << " " << ans << endl;

            a = b = 0;

            a = min(x, vr) - max(px, vl) + 1;
            b = min(ny, pr) - max(y, pl) + 1;

            a = max(a, 0LL);
            b = max(b, 0LL);

            ans += a*b;

          //  cout << i << " " << x << " " << y << " " << px << " " << ny << " " << a << " " << b << " " << ans << endl;

        }

        printf("%0.11f\n", (double)ans/(double)((pr-pl+1)*(vr-vl+1)));
    }

    return 0;
}

// IN THE NAME OF ALLAH
#include <math.h>
#include <vector>
#include <set>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include<cstring>
#include <cstdlib>
#include <string>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <bitset>

#define F first
#define S second
#define mp make_pair
#define L(x) (2*(x))
#define R(x) ((2*(x))+1)
#define pii pair<int , int>

using namespace std;
typedef long long ll;

const int N = 2e6 + 5 , Mod = 1e9 + 7 , MAXN = 1e8 + 1000 , LG = 30 , M = 1e6 + 5 , P = 727 , Sq = 100;
const ll inf = 3e18 + 10;

vector<int> v;
long double pl, pr, vl, vr, k;

long double check1(long double f1, long double f2){
      if(f2 < pl || f1 > pr)
            return 0;
      f1 = max(f1, pl);
      f2 = min(f2, pr);
      long double tt = (f2 - f1 + 1), pp = pr - pl + 1;
      tt /= pp;
      return tt;
}
long double check2(long double f1, long double f2){
      if(f2 < vl || f1 > vr)
            return 0;
      f1 = max(f1, vl);
      f2 = min(f2, vr);
      long double tt = (f2 - f1 + 1), pp = vr - vl + 1;
      tt /= pp;
      return tt;
}
int main(){
      ios_base::sync_with_stdio(0); cin.tie(0);
      cin >> pl >> pr >> vl >> vr >> k;
      for(int i = 1; i <= 11; i++){
            for(int j = 0; j < (1 << i); j++){
                  ll ret = 0;
                  for(int x = 0; x < i; x++){
                        if(((1 << x) & j) > 0)
                              ret *= 10, ret += 4;
                        else
                              ret *= 10, ret += 7;
                  }
                  v.push_back(ret);
            }
      }
      sort(v.begin(), v.end());
      long double res = 0;
      for(int i = k - 1; i < (int)v.size() - 1; i++){
            int l2 = v[i - k + 1], l1 = 0;
            if(i == k - 1)
                  l1 = 1;
            else
                  l1 = v[i - k] + 1;
            int r2 = v[i + 1] - 1, r1 = v[i];
            res += check1(l1, l2) * check2(r1, r2);
            res += check2(l1, l2) * check1(r1, r2);
      }
      cout << fixed << setprecision(12) << res << endl;
      return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<string>
#include<stack>
#include<queue>
using namespace std;
#define MAXI(a,b) ((a)>(b)?(a):(b))
#define MINI(a,b) ((a)<(b)?(a):(b))
#define MAXN 1000000000
vector < int > lucky;
map < int , int > Mp;
bool islucky(int x)
{
    int d;
    while (x)
    {
        d = x%10;
        if (d != 4 && d != 7) return false;
        x /= 10;
    }
    return true;
}
void gen(int n)
{
    if (n < 0 || n*10 > MAXN || !islucky(n)) return;
    //printf("%d\n", n);
    if (n) lucky.push_back(n);
    gen(n*10 + 4);
    gen(n*10 + 7);
}
void pre()
{
    lucky.clear(), Mp.clear();
    gen(0);
    sort (lucky.begin(), lucky.end());
    int i;
    for (i=0; i<lucky.size(); ++i)
    {
        //printf("%d\n", lucky[i]);
        Mp[lucky[i]] = i;
    }
    //printf("size = %d\n", lucky.size());
}
/*void prep(vector < int > &V, int l, int r)
{
    V.push_back(l);
    int i;
    for (i=0; i<lucky.size(); ++i)
    {
        if (lucky[i] > r) break;
        if (lucky[i] == l) continue;
        V.push_back(lucky[i]);
    }
    if (V[V.size()-1] != r) V.push_back(r);
}*/
long long count(int l1, int r1, int l2, int r2, int K)
{
    /*vector < int > V1,V2;
    V1.clear(), V2.clear();
    prep(V1,l1,r1), prep(V2,l2,r2);*/
    int i,j;
    long long ret = 0;
    int st1,nd1, st2,nd2;
    for (i=0; i<lucky.size(); ++i)
    {
        if (lucky[i] <= l1) continue;
        if (i && r1 < lucky[i-1]) break;
        st1 = l1;
        if (i) st1 = MAXI(l1,lucky[i-1]+1);
        nd1 = MINI(lucky[i],r1);
        j = i + K - 1;
        if (j >= lucky.size()) continue;
        st2 = lucky[j];
        if (j+1 < lucky.size()) nd2 = lucky[j+1]-1;
        else nd2 = r2;
        st2 = MAXI(st2,l2);
        nd2 = MINI(nd2,r2);
        if (st2 > nd2) continue;
        //printf("(%d %d) and (%d %d)\n", st1, nd1, st2, nd2);
        ret += (long long) (nd1-st1+1) * (nd2-st2+1);
    }
    return ret;
}
int main()
{
    pre();
    int l1,r1, l2,r2, K, i;
    long long ans;
    while (scanf("%d %d %d %d %d", &l1, &r1, &l2, &r2, &K) != EOF)
    {
        ans = count(l1,r1,l2,r2,K) + count(l2,r2,l1,r1,K);
        if (K == 1)
        {
            for (i=0; i<lucky.size(); ++i)
            {
                if (l1 <= lucky[i] && lucky[i] <= r1 && l2 <= lucky[i] && lucky[i] <= r2) --ans;
            }
        }
        printf("%.11lf\n", (double) ans / ((double) (r1-l1+1) * (r2-l2+1)));
    }
    return 0;
}

//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

set<int>s;
void dfs(int num)
{
    if(num>1e10)
        return ;
    s.insert(num);
    dfs(num*10+4);
    dfs(num*10+7);
}
int32_t main()
{
    IOS;
    dfs(4);dfs(7);
    vector<int>v;
    for(int i:s)
        v.push_back(i);
    int pl,pr,vl,vr,k;
    cin>>pl>>pr>>vl>>vr>>k;
    int total=0;
    for(int i=0;i<1030;i++)
    {
        int num1=v[i];
        int num2=v[i+k-1];

        int l1,r1,l2,r2;
        l1= (i==0)?pl-1:max(v[i-1],pl-1);
        r1= min(pr,num1);
        l2= max(num2-1,vl-1);
        r2= min(vr,v[i+k]-1);
        if(!(l1>r1 || l2>r2))
            total+=(r1-l1)*(r2-l2);

        l1= (i==0)?vl-1:max(v[i-1],vl-1);
        r1= min(vr,num1);
        l2= max(num2-1,pl-1);
        r2= min(pr,v[i+k]-1);
        if(!(l1>r1 || l2>r2))
            total+=(r1-l1)*(r2-l2);
    }
    cout<<fixed<<setprecision(12)<<total*1.0/(pr-pl+1)/(vr-vl+1)<<endl;
}

#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stdio.h>
#include <stack>
#include <ctime>
#include <list>
#include <map>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
#define TR(i,x) for(typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))

using namespace std;

const double eps = 1e-8;

#define PB push_back
#define MP make_pair

typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int,int> PII;
typedef long long ll;
typedef long double LD;
typedef unsigned long long ULL;

ll all[1000000];
int total = 0;

void gen(int dep,ll now)
{
    if (dep >= 10) return;
    if(now) all[total++] = now;
    gen(dep+1,now*10+4);
    gen(dep+1,now*10+7);
}

int main()
{
    gen(0,0);
    sort(all,all+total);
    ll pl,pr,vl,vr,k,al,ar;
    cin >> al>>ar>>vl >>vr >> k;
    long long up = 0;
    int lower = al,upper = vl;
    //cout << all[100] << endl;
    int lid = 0,rid = 0;
    int l = 0,r = total;
    while (l < r)
    {
        int mid = ((l+r)>>1)+1;
        if (all[mid] <= vl)
            l = mid;
        else
            r = mid-1;
    }
    lid = l;
    l = 0,r = total;
    while (l < r)
    {
        int mid = ((l+r)>>1)+1;
        if (all[mid] <= vr)
            l = mid;
        else
            r = mid-1;
    }
    rid = l;
    //cout << lid << " " << rid << endl;
    for (int i = 0;i < total;++i)
    {
        if (all[i] >= lower)
        {
            if (i+k-1 < total)
            {
                if (i+k-1>= lid && i+k-1 <= rid)
                {
                    int bound = i+k-2 >= 0 ? all[i+k-2]+1 : 1;
                    up += (min(ar,all[i])-lower+1) * (min(vr,all[i+k]-1)-max(vl,all[i+k-1])+1);
                }
            }
            lower = all[i]+1;
            if (lower > ar) break;
        }
    }
    swap(al,vl);
    swap(ar,vr);
    lower = al,upper = vl;
    //cout << all[100] << endl;
    lid = 0,rid = 0;
    l = 0,r = total;
    while (l < r)
    {
        int mid = ((l+r)>>1)+1;
        if (all[mid] <= vl)
            l = mid;
        else
            r = mid-1;
    }
    lid = l;
    l = 0,r = total;
    while (l < r)
    {
        int mid = ((l+r)>>1)+1;
        if (all[mid] <= vr)
            l = mid;
        else
            r = mid-1;
    }
    rid = l;
    for (int i = 0;i < total;++i)
    {
        if (all[i] >= lower)
        {
            if (i+k-1 < total)
            {
                if (i+k-1>= lid && i+k-1 <= rid)
                {
                    int bound = i+k-2 >= 0 ? all[i+k-2]+1 : 1;
                    up += (min(ar,all[i])-lower+1) * (min(vr,all[i+k]-1)-max(vl,all[i+k-1])+1);
                }
            }
            lower = all[i]+1;
            if (lower > ar) break;
        }
    }
    if (1 == k)
    {
        lid = 0,rid = 0;
        l = 0,r = total;
        while (l < r)
        {
            int mid = ((l+r)>>1);
            if (all[mid] >= vl)
                r = mid;
            else
                l = mid+1;
        }
        lid = l;
        l = 0,r = total;
        while (l < r)
        {
            int mid = ((l+r)>>1)+1;
            if (all[mid] <= vr)
                l = mid;
            else
                r = mid-1;
        }
        ll tmp = r - lid + 1;
        swap(al,vl);
        swap(ar,vr);
        lid = 0,rid = 0;
        l = 0,r = total;
        while (l < r)
        {
            int mid = ((l+r)>>1);
            if (all[mid] >= vl)
                r = mid;
            else
                l = mid+1;
        }
        lid = l;
        l = 0,r = total;
        while (l < r)
        {
            int mid = ((l+r)>>1)+1;
            if (all[mid] <= vr)
                l = mid;
            else
                r = mid-1;
        }
        tmp = (tmp)*(r-lid+1);
    }
    long long down = (long long)(ar-al+1) * (long long)(vr-vl+1);
   // cout << up << " " << down << endl;
    printf("%.15f\n",(double)up/(double)down);
    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const ll oo = 1ll<<60;
ll pl, pr,vl,vr,maxi,mini;
vector<ll> numeros;
int K;

void bf(int pos,int can,ll pot,ll act){
	if(pos >= 10){
		if(mini <= act && act <= maxi){
			numeros.pb(act);
		}
		return;
	}
	if(can){
		bf(pos+1,1,pot/10,act);
	}
	bf(pos+1,0,pot/10,act+4ll*pot);
	bf(pos+1,0,pot/10,act+7ll*pot);
}
ll inter(ll l1,ll r1, ll l2,ll r2){
	ll inter = min(r1,r2)-max(l1,l2)+1;
	if(inter < 0)return 0;
	return inter;

}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> pl >> pr >> vl >> vr >> K;
	maxi = max({pr,vr});
	mini = min({pl,vl});
	bf(0,1,1000000000,0);
	ll den = (pr-pl+1)*(vr-vl+1);
	ll num = 0;
	/*forn(i,0,numeros.size())cout << numeros[i] << ' ';
	cout << "D:\n";*/
	forn(i,0,numeros.size()){
		int j = i+K-1;
		if(j >= numeros.size())break;
		ll ini1 = (i == 0) ? 1 : numeros[i-1]+1;
		ll fin1 = numeros[i];

		ll ini2 = numeros[j];
		ll fin2 = (j == numeros.size()-1) ? oo : numeros[j+1]-1;

		num += inter(pl,pr,ini1,fin1)*inter(vl,vr,ini2,fin2);
		num += inter(pl,pr,ini2,fin2)*inter(vl,vr,ini1,fin1);
	}
	//cout << num << ' ' << den << ":D\n";
	cout << fixed << setprecision(10) << min(ld(num)/ld(den),ld(1)) << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <sstream>

//Hendri's Template
#define REP(i, n) for(int i = 0, _n = (n); i < _n; i++)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, a, b) for(int i = (a), _b = (b); i >= _b; i--)
#define RESET(A,v) memset(A, v, sizeof(A))

#define MP make_pair
#define PB push_back
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

template<class T> inline T MIN(T a, T b){return a < b?a:b;}
template<class T> inline T MAX(T a, T b){return a > b?a:b;}

template<class T> inline void getInt(T& x)
{
	char c;
	int mul = 1;
	while((c = getchar()) != EOF)
	{
		if(c == '-')mul = -1;
		if(c >= '0' && c <= '9')
		{
			x = c-'0';
			break;
		}
	}
	if(c == EOF){x = EOF;return;}
	while(c = getchar())
	{
		if(c >= '0' && c <= '9')
		{
			x = (x<<1)+(x<<3)+(c-'0');
		}
		else break;
	}
	x *= mul;
}
//End of Hendri's Template

ll k,a,b,c,d;
vector<ll> v;

void gen(string s,int l)
{
	if(s.length() == l)
	{
		if(atoll(s.c_str()) < 0)cout << s << endl;
		v.PB(atoll(s.c_str()));
	}
	else
	{
		gen(s+"4",l);
		gen(s+"7",l);
	}
}

int main()
{
	v.PB(0);
	FOR(i,1,12)
	{
		gen("",i);
	}
	sort(v.begin(),v.end());
	getInt(a);getInt(b);getInt(c);getInt(d);
	getInt(k);
	double ok = 0;
	cout << v[v.size()-1] << endl;
	FOR(i,1,v.size()-1)
	{
		int j = i+k-1;
		if(j < v.size())
		{
			if(!(a > v[i] || b <= v[i-1] || c >= v[j+1] || d < v[j]))
			{
				ll lo = MIN(v[i],b)-MAX(v[i-1]+1,a)+1;
				ll hi = MIN(v[j+1]-1,d)-MAX(v[j],c)+1;
				if(lo > 0 && hi > 0)
				{
					ok += 1.0*lo/(b-a+1)*hi/(d-c+1);
				}
			}
			if(!(c > v[i] || d <= v[i-1] || a >= v[j+1] || b < v[j]))
			{
				ll lo = MIN(v[i],d)-MAX(v[i-1]+1,c)+1;
				ll hi = MIN(v[j+1]-1,b)-MAX(v[j],a)+1;
				if(lo > 0 && hi > 0)
				{
					ok += 1.0*lo/(d-c+1)*hi/(b-a+1);
				}
			}
		}
	}
	printf("%.12f\n",ok);
	return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#pragma comment(linker,"/STACK:16777216")
#define inf 1000000000
#define MP make_pair
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
vector<int> lck;
int n,C[10];
int pl,pr,vl,vr,k;

void createLucky(int idx){
    if(idx==n+1){
        int num=0;
        for(int i=1;i<=n;i++){num*=10;num+=C[i];}
        lck.push_back(num);
    }
    else{
        C[idx]=4; createLucky(idx+1);
        C[idx]=7; createLucky(idx+1);
    }
}

double f(int l,int r,int L,int R){

    if(r<L||l>R)return 0.0;
    return 1.0*(min(r,R)-max(l,L)+1)/(R-L+1);

}

int main()
{

    for(int i=1;i<=9;i++){n=i; createLucky(1);}

    sort(lck.begin(),lck.end());
    //for(int i=0;i<lck.size();i++)cout<<lck[i]<<endl;

    cin>>pl>>pr>>vl>>vr>>k;

    double res=0.0;
    for(int i=0;i<lck.size();i++)
        if(i+k-1<lck.size()){

            //choose p>lck[i-1] and p<=lck[i]
            //choose v>=lck[i+k-1] and v<lck[i+k]
            int l1=(i?(lck[i-1]+1):1);
            int r1=lck[i];

            int l2=lck[i+k-1];
            int r2=((i+k<lck.size())?(lck[i+k]-1):inf);

            res+=f(l1,r1,pl,pr)*f(l2,r2,vl,vr);
            res+=f(l1,r1,vl,vr)*f(l2,r2,pl,pr);

        }

    printf("%.15f\n",res);
    return 0;
}

// Alex Fetisov
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <sstream>
#include <deque>
#include <cmath>
#include <string>
#include <vector>
#include <queue>

void initf() {
	//freopen("b.in", "r", stdin);
	//freopen("b.out", "w", stdout);
}

using namespace std;

#define fr(i,a,b) for ( int i = ( a ); i <= ( b ); ++i )
#define fi(a) for ( int i = 0; i < ( a ); ++i )
#define fj(a) for ( int j = 0; j < ( a ); ++j )
#define fk(a) for ( int k = 0; k < ( a ); ++k )
#define CLR(a,b) memset( ( a ), ( b ), sizeof( ( a ) ) )
#define clr(a) CLR((a),0)
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef vector < int > vi;
typedef pair < int, int > pii;

const int inf = ( 1 << 30 );

bool inMask(int mask, int b) {
	return (mask & (1 << b));
}

vi goods;
int pl, pr, vl, vr, K;

double calc(int pLe, int cLe, int cRi, int nRi) {
	// pet letf
	int le = max(pLe, pl);
	int ri = min(cLe, pr);
	int len1 = ri - le + 1;
	double p1;
	double ret = 0;
	if (len1 > 0) {
		p1 = (1. * len1) / (1. * pr - pl + 1);
		le = max(cRi, vl);
		ri = min(nRi, vr);
		len1 = ri - le + 1;
		if (len1 > 0) {
			p1 *= (1. * len1) / (1. * vr - vl + 1);
			ret += p1;
		}
	}
	le = max(pLe, vl);
	ri = min(cLe, vr);
	len1 = ri - le + 1;
	if (len1 > 0) {
		p1 = (1. * len1) / (1. * vr - vl + 1);
		le = max(cRi, pl);
		ri = min(nRi, pr);
		len1 = ri - le + 1;
		if (len1 > 0) {
			p1 *= (1. * len1) / (1. * pr - pl + 1);
			ret += p1;
		}
		}
	return ret;
}

void solve() {
	fr(len,1,8) {
		fi(1<<len) {
			int num = 0;
			fj(len) {
				if (inMask(i, j)) {
					num = num * 10 + 4;
				} else {
					num = num * 10 + 7;
				}
			}
			goods.pb(num);
		}
	}
	goods.pb(0);
	goods.pb(1000000001);
	sort(all(goods));
	double ret = 0;
	cin >> pl >> pr >> vl >> vr >> K;
	for (int i = 1, j = K; j < (int)goods.size() - 1; ++i, ++j) {
		int curLe = goods[i];
		int prevLe = goods[i-1] + 1;
		int curRi = goods[j];
		int prevRi = goods[j+1] - 1;
		ret += calc(prevLe, curLe, curRi, prevRi);
	}
	printf("%.9lf\n", ret);
}

int main() {
 	initf();
 	solve();
 	return 0;
}

#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<20|1],*p1=buf,*p2=buf,obuf[1<<20|1],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }
int l1,l2,r1,r2,k,L,R;
int a[N],n;
void dfs (int x)
{
	if (x> R) return ;
	if (x) a[++n]=x;
	dfs (x*10+4),dfs (x*10+7);
}
int cross (int l1,int r1,int l2,int r2)
{
	return max (0,min (r1,r2)-max (l1,l2)+1);
}

int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	sc(l1),sc(r1),sc(l2),sc(r2),sc(k);
	R=max (r1,r2);
	dfs (0);
	sort (a+1,a+n+1); a[++n]=oo;
	LL ans=0;
	for (int i=1; i<=n-k+1; i++)
	{
		L=a[i],R=a[i+k-1];
		ans+=(LL)cross (a[i-1]+1,a[i],l1,r1)*cross (a[i+k-1],a[i+k]-1,l2,r2);
		ans+=(LL)cross (a[i-1]+1,a[i],l2,r2)*cross (a[i+k-1],a[i+k]-1,l1,r1);
	}
	printf ("%.12lf\n",(db)ans/(r1-l1+1)/(r2-l2+1));

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define mod 1000000007
#define bitcount __builtin_popcountll
#define ll long long
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<pi,ll>
#define mp make_pair
int main()
{
	ll i,j,k;
	ll p1,p2,v1,v2;
	cin>>p1>>p2>>v1>>v2>>k;
	queue<ll>q;
	vector<ll>v;
	q.push(0);
	ll ans=0;
	while(!q.empty())
	{
		ll x=q.front();
		if(x<1e9)
		{
			v.pb(x);
			q.push(x*10+4);
			q.push(x*10+7);
		}
		q.pop();
	}
	sort(v.begin(), v.end());
	v.pb(1e9);
	for(i=1;i<v.size()-k+1;i++)
	{
		j=i+k-1;
		// printf("%lld %lld\n",v[i],v[j] );
		ans+=max(0ll,(max(0ll,min(p2,v[i])-max(p1-1,v[i-1])))*(max(0ll,min(v2+1,v[j+1])-max(v1,v[j]))));
		// printf("%lld\n",ans );
		ans+=max(0ll,(max(0ll,min(v2,v[i])-max(v1-1,v[i-1])))*(max(0ll,min(p2+1,v[j+1])-max(p1,v[j]))));
		// if(k==1&&v[i]>=p1&&v[i]<=p2&&v[i]>=v1&&v[i]<=v2)
		// 	ans--;
		// printf("%lld\n",ans );
	}
	printf("%0.12lf\n",(double)ans/(double)((p2-p1+1)*(v2-v1+1)) );
	return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <map>

#define REP(a,b) for (int a=0; a<b; a++)
#define FORU(a,b,c) for (int a=b; a<=c; a++)
#define FORD(a,b,c) for (int a=b; a>=c; a--)
#define RESET(a,b) memset(a, b, sizeof a)

#define INF 2123123123
#define LOLO long long
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PII pair<int,int>

#define __ puts("")

using namespace std;

vector<int> luc;
int a[2], b[2],ba,bb,ca,cb,tot;
double prob,t1,t2,p1,p2;

int main(){
//   freopen("in.txt","r",stdin);
//   freopen("ot.txt","w",stdout);

   scanf("%d%d%d%d%d", &a[0],&b[0],&a[1],&b[1],&tot);

   if ((a[0]==a[1]) && (a[0]==b[0]) && (a[0]==b[1])){
      printf("%.12lf\n", 1.);
      return 0;
   }

   luc.PB(0);
   luc.PB(INF);

   FORU(k,1,9){
      REP(i,1<<k){
         int dop=0;
         REP(j,k){
            if (i & (1<<j)){
               dop=(dop*10) + 4;
            }else{
               dop=(dop*10) + 7;
            }
         }

         luc.PB(dop);
      }
   }

   sort(luc.begin(), luc.end());

   prob=0;
   REP(k,2){
      t1=b[0]-a[0]+1;
      t2=b[1]-a[1]+1;

      FORU(i,1,luc.size()-tot){
         ba=max(a[0], luc[i-1]+1);
         bb=min(b[0], luc[i]);

         ca=max(a[1], luc[i+tot-1]);
         cb=min(b[1], luc[i+tot]-1);

         if ((ba<=bb) && (ca<=cb)){
            p1=(bb-ba+1);
            p2=(cb-ca+1);

            prob+=(p1/t1)*(p2/t2);

//            printf("%d %d, %d %d\n", ba,bb, ca,cb);
         }
      }

      swap(a[0],a[1]);
      swap(b[0],b[1]);

      if ((a[0]==b[0]) || (a[1] == b[1])) break;
   }

   printf("%.12lf\n", prob);
//   system("pause");
//   fclose(stdin);
//   fclose(stdout);
   return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <bitset>
#include <queue>
using namespace std;
long long mass[10*1000];
int size=1;
int main()
{
//  freopen("in.in","r",stdin);
//  freopen("out.out","w",stdout);
    long long pl,pr,vl,vr,k;

    cin>>pl>>pr>>vl>>vr>>k;
    long long maxd=max(vr,pr);
    long long mx=6000ll*1000*1000;
    for (int tw=2;;tw<<=1)
    {
        long long a=0;
        for (int mask=0;mask<tw;mask++)
        {
            a=0;
            int j=tw>>1;
            while (j)
            {
                a*=10ll;
                if (mask&j)
                {
                    a+=7;
                }
                else
                    a+=4;
                j>>=1;
            }
            mass[size++]=a;
            if (mask==tw)
            {
                tw<<=1;
                mask--;
            }
            if (a>mx)
            {
                break;
            }
        }
        if (a>mx)
        {
            break;
        }
    }
//  cout<<size<<endl;

    double res=0.0;
    for (int curu=k;curu<size;curu++)
    {
        if (mass[curu]>maxd)
            break;
        int curd=curu-k+1;
        long long upr,upl,downr,downl;
        upr=mass[curu+1]-1;
        upl=mass[curu];
        if (curd>1)
            downl=mass[curd-1]+1;
        else
            downl=1;
        downr=mass[curd];

        double p1,p2;
        if (downl>pr||downr<pl)
            p1=0.0;
        else
            p1=(min(downr,pr)-max(downl,pl)+1.0)/(pr-pl+1.0);
        if (upl>vr||upr<vl)
            p2=0.0;
        else
            p2=(min(upr,vr)-max(upl,vl)+1.0)/(vr-vl+1.0);
        res+=p1*p2;
        {
            swap(pl,vl);
            swap(pr,vr);
        }
        if (k==1)
        {
            upl++;
        }
        if (downl>pr||downr<pl)
            p1=0.0;
        else
            p1=(min(downr,pr)-max(downl,pl)+1.0)/(pr-pl+1.0);
        if (upl>vr||upr<vl)
            p2=0.0;
        else
            p2=(min(upr,vr)-max(upl,vl)+1.0)/(vr-vl+1.0);
        res+=p1*p2;
        {
            swap(pl,vl);
            swap(pr,vr);
        }
    }
    printf("%.15lf",res);
    return 0;
}

//#include "stdafx.h"
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <math.h>
#include <map>
#include <algorithm>
#include <set>
#include<complex>
#include <stdio.h>
#include<stdint.h>
#include<iterator>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#define ll long long
#define ld long double

#define forin for(fint i = 0; i < n; i++)
#define forkm for(fint k = 0; k < m; k++)
#define forjp for(fint j =0; j < p; j++)
#define all(x) x.begin(), x.end()
#define INF 99999999999
#define fint int_fast32_t
#define mp(x,y) make_pair(x,y)
#define cmp complex<double>

using namespace std;

const double PI = 3.14159265358979323846264338327;

ll n, A;

struct triple
{
	ll first;
	ll second;
	ll ind;
};

bool comp1(triple x, triple y)
{
	return x.first < y.first;
}

bool comp2(triple x, triple y)
{
	if (x.first + x.second != y.first + y.second)
		return A - (x.first + x.second) < A - (y.first + y.second);
	else
		return x.second > y.second;
}
vector<ld> arr;
void build (ll len, ll num) {
	if (!len) {
		arr.push_back(num);
		return;
	}
	build(len - 1, num * 10 + 4);
	build(len - 1, num * 10 + 7);
}
int f (int x, int y, int l, int r) {
	return max(min(y, r) - max(x, l) + 1, 0);
}

int main () {
	arr.push_back(0);
	for (int i = 1; i <= 9; i++) {
		build(i, 0);
	}
	arr.push_back(1000000000);
	ll l1, r1,l2,r2, k;
	cin >> l1 >> r1 >> l2 >> r2;
	cin >> k;
	ld ans = 0;
	for (int i = 1; i + k - 1 < arr.size() - 1; i++) {
		ans += (ll) f(arr[i - 1] + 1, arr[i], l1,r1) * f(arr[i + k - 1], arr[i + k] - 1, l2, r2);
		ans += (ll) f(arr[i - 1] + 1, arr[i], l1, r1) * f(arr[i + k - 1], arr[i + k] - 1, l2, r2);
	}
	if (k == 1) {
		for (int i = 1; i + k - 1 < arr.size() - 1; i++) {
			if (l2 <= arr[i] && arr[i] <= r2 && l1 <= arr[i] && arr[i] <= r1) {
				ans--;
			}
		}
	}
	ans /= r2 - l2 + 1;
	ans /= r1 - l1 + 1;
	//cout << ans << endl;
	cout << std::setprecision(11) << ans;
	//system("pause");
	return 0;
}
/* Mon Oct 16 2017 20:55:04 GMT+0300 (MSK) */

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <ctime>
#include <functional>
#include <stack>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

vector<ll> A;

void calc(){

    A.push_back(4);
    A.push_back(7);
    for(int i=0;i<A.size();++i){
        if(A[i]>=1e8) continue;
        A.push_back(A[i]*10 + 4);
        A.push_back(A[i]*10 + 7);
    }
}

int main(){
    //freopen("line3.in","r",stdin);
    //freopen("line3.out","w",stdout);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    calc();
    ll pl,pr,vl,vr,k;
    ll ans = 0;

    cin >> pl >> pr >> vl >> vr >> k;

    for(int i=0; i+k-1<A.size(); ++i){
        ll MinP = pr, MaxV = vl, MinV = vr, MaxP = pl;
        if(A[i]!=47) continue;
        if(A[i]<pl || (i-1>=0 && A[i-1]>=pr)) MinP = 0;
        else
            MinP = min(pr,A[i]) - max(i-1>=0?A[i-1]+1:0ll,pl) + 1;

        if(A[i+k-1]>vr || (i+k<A.size() && A[i+k]<=vl)) MaxV = 0;
        else
            MaxV = -max(vl,A[i+k-1]) + min(i+k<A.size()?A[i+k]-1:100000000000ll,vr) + 1;

        if(A[i]<vl || (i-1>=0 && A[i-1]>=vr)) MinV = 0;
        else
            MinV = min(vr,A[i]) - max(i-1>=0?A[i-1]+1:0ll,vl) + 1;

        if(A[i+k-1]>pr || (i+k<A.size() && A[i+k]<=pl)) MaxP = 0;
        else
            MaxP = -max(pl,A[i+k-1]) + min(i+k<A.size()?A[i+k]-1:1000000000000ll,pr) + 1;

        //cout << MinP << ' ' << MaxV << ' ' << MinV << ' ' << MaxP << endl;

        ans += MinP * MaxV;
        if(MinV*MaxP>1)
        ans += MinV * MaxP;

    }

    long double answer = (long double) ans / ((long double) (pr - pl + 1) * (vr - vl + 1));

    cout << fixed << setprecision(12)  << answer;
    return 0;
}

#include <bits/stdc++.h>

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

vector<int> lucky;

void backtrack(ll n) {
	if(n > 1e9) return ;
	lucky.push_back((int)n);
	backtrack(n*10 + 4);
	backtrack(n*10 + 7);
}

int main(){
	int pl, pr, vl, vr, k;

	scanf("%d%d%d%d%d", &pl, &pr, &vl, &vr, &k);

	backtrack(4);
	backtrack(7);

	lucky.push_back(0);
	lucky.push_back(1000000001);
	sort(lucky.begin(), lucky.end());

	int l = 1, r = k;

	ll tot = ((ll)pr-pl+1)*((ll)vr-vl+1);
	ll ans = 0;
	while(r < (int)lucky.size()-1) {
		int lft1 = max(pl, lucky[l-1]+1);
		int rgt1 = min(pr, lucky[l]);

		int lft2 = max(vl, lucky[r]);
		int rgt2 = min(vr, lucky[r+1]-1);

		ans += max<ll>(rgt1 - lft1 + 1, 0)*max<ll>(rgt2 - lft2 + 1, 0);

		lft1 = max(vl, lucky[l-1]+1);
		rgt1 = min(vr, lucky[l]);

		lft2 = max(pl, lucky[r]);
		rgt2 = min(pr, lucky[r+1]-1);

		ans += max<ll>(rgt1 - lft1 + 1, 0)*max<ll>(rgt2 - lft2 + 1, 0);
		r++;
		l++;
	}

	printf("%.15lf\n", (double)ans/tot);

	return 0;
}

#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <algorithm>
using namespace std;

#define nln        puts("")                         ///prLLInewline
#define getLLI(a)  scanf("%d",&a);
#define mx3(a,b,c) mx(a,mx(b,c))                  ///3 ta theke mx
#define min3(a,b,c) min(a,min(b,c))                  ///3 ta theke min

#define FOR1(i,n)  for(LLI i=1;i<=n;i++)
#define FOR0(i,n)  for(LLI i=0;i<n;i++)                 ///looping
#define FORR(i,n)  for(LLI i=n-1;i>=0;i--)
#define ALL(p)     p.begin(),p.end()

#define SET(p)     memset(p,-1,sizeof(p))
#define CLR(p)     memset(p,0,sizeof(p))            ///memset
#define MEM(p,v)   memset(p,v,sizeof(p))

#define READ(f)    freopen(f, "r", stdin)           /// file
#define WRITE(f)   freopen(f, "w", stdout)

#define SZ(c)      (LLI)c.size()
#define PB(x)      push_back(x)                     ///STL defines
#define MP(x,y)    make_pair(x,y)
#define ff         first
#define ss         second

#define LI         long LLI
#define LLI       long long
#define f64        long double
#define PI         acos(-1.0)                        ///PI er value

LLI Set(LLI N,LLI pos)
{
    return N=N | (1<<pos);
}
LLI reset(LLI N,LLI pos)
{
    return N= N & ~(1<<pos);
}
bool check(LLI N,LLI pos)
{
    return (bool)(N & (1<<pos));
}
void CI(LLI &_x)
{
    scanf("%d",&_x);
}

void CO(LLI &_x)
{
    cout<<_x;
}

template<typename T> void getarray(T a[],LLI n)
{
    for(LLI i=0; i<n; i++) cin>>a[i];
}
template<typename T> void prLLIarray(T a[],LLI n)
{
    for(LLI i=0; i<n-1; i++) cout<<a[i]<<" ";
    cout<<a[n-1]<<endl;
}

const double EPS=1e-9;                              ///constatnts
const LLI INF=0x7f7f7f7f;

LLI dr8[8]= {1,-1,0,0,1,-1,-1,1};            ///8 direction move
LLI dc8[8]= {0,0,-1,1,1,1,-1,-1};
LLI dr4[4]= {0,0,1,-1};                      ///4 direction move
LLI dc4[4]= {-1,1,0,0};                      ///or adjacent dir.
LLI kn8r[8]= {1,2,2,1,-1,-2,-2,-1};          ///knight moves
LLI kn8c[8]= {2,1,-1,-2,-2,-1,1,2};

map<int,int>lucky;
LLI l,h;
void rec(LLI num,vector<int>&V)
{

    if(num>h)return;

    if(num>=l&&num<=h)
    {
        lucky[num]=1;
        V.PB(num);
    }
    rec((num*10)+4,V);
    rec((num*10)+7,V);
}
map<int,int>prefix_sum;
int main()
{

    vector<int>v,v1,v2;
    int pl,pr;
    cin>>pl>>pr;
    if(pl>pr)swap(pl,pr);
    l=pl,h=pr;
    rec(0,v1);

    int vl,vr;
    cin>>vl>>vr;
    if(vl>vr)swap(vl,vr);

    l=vl,h=vr;
    rec(0,v2);

    l=min(vl,pl),h=max(pr,vr);
    rec(0,v);
    sort(ALL(v));

    for(int i=0; i<v.size(); i++)
    {
        prefix_sum[v[i]]=1;
//        if(i>0)
//        {
//            prefix_sum[v[i]]+=prefix_sum[v[i-1]];
//        }

    }
    v.PB(pl),v.PB(pr),v.PB(vr),v.PB(vl);
    sort(ALL(v));

    for(int i=1; i<v.size(); i++)
    {
//        {
        prefix_sum[v[i]]+=prefix_sum[v[i-1]];
//        }

    }
    v1.PB(pl);
    v1.PB(pr);
    v2.PB(vl);
    v2.PB(vr);
    sort(ALL(v1));
    sort(ALL(v2));
    double ans=0;
    int k;
    cin>>k;
    for(int i=1; i<v1.size(); i++)
        for(int j=0; j<v2.size()-1; j++)
        {
//            int big=v2[j],small=v1[i];
            if(prefix_sum[v2[j]]-prefix_sum[v1[i]]+lucky[v1[i]]!=k)continue;
//            cout<<v1[i]<<" & "<<v2[j]<<"  = "<<prefix_sum[v2[j]]-prefix_sum[v1[i]]+1<<"\n";
//puts("FUCK");
            LLI m1,m2;
            m1=v1[i]-v1[i-1]+1;
            m2=v2[j+1]-v2[j]+1;
            ans+=(m1*m2);
        }
    for(int i=1; i<v2.size(); i++)
        for(int j=0; j<v1.size()-1; j++)
        {
            if(prefix_sum[v1[j]]-prefix_sum[v2[i]]+lucky[v2[i]]!=k)continue;
            LLI m1,m2;
            m1=v2[i]-v2[i-1]+1;
            m2=v1[j+1]-v1[j]+1;
            ans+=(m1*m2);

        }

    cout<<setprecision(10)<<ans/((pr-pl+1)*(vr-vl+1)*1.0)<<"\n";
}

#include<iostream>
#include<cstdio>
#include<cstring>

#include<map>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>

typedef long long LL;
#define SI(x) scanf("%d",&x)
#define PI(x) printf("%d\n",x)
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

int pl,pr,vl,vr,k;
vector<int> lucky;
bool ok[4];

void gen(LL num)
{
	if(num>max(vr,pr)) return;
	if(num!=0)
	{
		if(num>=min(pl,vl)) lucky.PB((int)(num));
		if(num==pl) ok[0] = true;
		if(num==pr) ok[1] = true;
		if(num==vl) ok[2] = true;
		if(num==vr) ok[3] = true;
	}
	gen(num*10l+4);
	gen(num*10l+7);
}

int main()
{
	SI(pl);
	SI(pr);
	SI(vl);
	SI(vr);
	SI(k);
	gen(0);

	double ans = 0.0;

	int s = 0, e = 0, t = lucky.size();

	if(t<k)
	{
		cout<<ans<<endl;
		return 0;
	}
	sort(lucky.begin(),lucky.end());

	for(int i=0;i<t;i++)
	{
		s = i;
		e = s+k-1;
		if(e>=t) continue;

		if(lucky[s]<min(pl,vl) || lucky[e]>max(vr,pr)) continue;

		int ppl = pl, ppr = pr, vvl = vl, vvr = vr;

		for(int j=s-1;j>=0;j--)
		{
			if(lucky[j]>=ppl && lucky[j]<=ppr)
			{
				pl = lucky[j]+1;
				break;
			}
		}
		for(int j=s-1;j>=0;j--)
		{
			if(lucky[j]>=vvl && lucky[j]<=vvr)
			{
				vl = lucky[j]+1;
				break;
			}
		}
		for(int j=e+1;j<t;j++)
		{
			if(lucky[j]>=ppl && lucky[j]<=ppr)
			{
				pr = lucky[j]-1;
				break;
			}
		}
		for(int j=e+1;j<t;j++)
		{
			if(lucky[j]>=vvl && lucky[j]<=vvr)
			{
				vr = lucky[j]-1;
				break;
			}
		}

		if(lucky[s]>=pl && lucky[e]<=vr){
			int samp_p = min(lucky[s],pr)-pl+1;
			int samp_v = vr - max(lucky[e],vl)+1;
			int den_p = pr-pl+1, den_v = vr-vl+1;

			if(ok[0])
			{
				if(lucky[s]!=pl)den_p--;
			}
			if(ok[3])
			{
				if(lucky[e]!=vr) den_v--;
			}

			if(k==1)
			{
				if(vl==lucky[e]) vl++;
				 samp_v = vr - max(lucky[e]+1,vl)+1;
				 if(samp_v<0)samp_v = 0;
			}

			double p = 1.0*samp_p/den_p;
			double v = 1.0*samp_v/den_v;
			ans+=(p*v);
		}
		if(lucky[s]>=vl && lucky[e]<=pr){
			int samp_v = min(lucky[s],vr)-vl+1;
			int samp_p = pr - max(lucky[e],pl)+1;
			int den_p = pr-pl+1, den_v = vr-vl+1;
			if(ok[1])
			{
				if(lucky[s]!=vl)den_v--;
			}
			if(ok[2])
			{
				if(lucky[e]!=pr) den_p--;
			}

			double p = 1.0*samp_p/den_p;
			double v = 1.0*samp_v/den_v;
			ans+=(p*v);
		}

		pl = ppl;
		pr = ppr;
		vl = vvl;
		vr = vvr;

	}

	printf("%.9lf\n",ans);

	return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>

using namespace std;

#define MAX 200005

typedef long long ll;

set<ll> ld;
vector<ll> pk;

void gen(ll st, ll mx)
{
    if(st > mx)
        return;
    ld.insert(st);
    gen(st * 10 + 4, mx);
    gen(st * 10 + 7, mx);
}

int main() {

    ll p1, p2, v1, v2, k;
    cin >> p1 >> p2 >> v1 >> v2 >> k;

    ll p = (p2 - p1 + 1), v = (v2 - v1 + 1);
    ll sum = 0;
    gen(0, max(p2, v2));
    ld.insert(max(p2, v2) + 1);

    pk.push_back(0);
    for(set<ll>::iterator it = ld.begin(); it != ld.end(); ++it)
        pk.push_back(*it);

    for(int i = 1; i + k < pk.size(); ++i)
    {
        ll l1 = max(pk[i - 1] + 1, p1);
        ll l2 = min(pk[i + k] - 1, p2);

        ll m1 = max(pk[i - 1] + 1, v1);
        ll m2 = min(pk[i + k] - 1, v2);

        if(m1 <= pk[i] && l2 < pk[i + k] && m1 <= v2 && l2 >= p1 && m1 >= pk[i - 1] + 1 && l2 >= pk[i + k - 1])
        {
            //cout << m1 << " " << l2 << endl;
            sum += (l2 - max(p1, pk[i + k - 1]) + 1) * (min(v2, pk[i]) - m1 + 1);
        }
        if(l1 <= pk[i] && m2 < pk[i + k] && l1 <= p2 && m2 >= v1 && l1 >= pk[i - 1] + 1 && m2 >= pk[i + k - 1]
            && (m1 != l1 && m2 != l2 && l2 - l1 != 1))
        {
            //cout << l1 << " " << m2 << endl;
            sum += (m2 - max(v1, pk[i + k - 1]) + 1) *  (min(p2, pk[i]) - l1 + 1);
        }
    }

    //cout << sum << " " << p * v << endl;
    cout.precision(11);
    cout << double(sum) / (p * v);
}

#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

#define all(x) x.begin(), x.end()
#define f(i,a,b) for(int i = (a); i <= (b); i++)
#define fd(i,a,b) for(int i = (a); i >= (b); i--)
#define mp make_pair
#define faster_io() ios_base::sync_with_stdio(false)
#define pb push_back
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
#define vii vector<pair<int,int>>

const ll INF = 1000000002;
const ll INFLL = 100000000000000000ll;
const ll MOD = 1000000007;

// ----------------------------------------------------------------------------------------------------------

ll PL, PR, VL, VR, K;
vector<ll> V;

void proc(ll n)
{
    if(n>INF*10) return;
    if(n>0) V.pb(n);
    proc(n*10+4);
    proc(n*10+7);
}

int main()
{
    proc(0);
    sort(all(V));
    cin >> PL >> PR >> VL >> VR >> K;
    double ans = 0;
    f(b,K-1,SZ(V)-2)
    {
        ll l1 = b==K-1?1:V[b-K] + 1;
        ll r1 = V[b-K+1];
        ll l2 = V[b];
        ll r2 = V[b+1] - 1;

        ll com_l = max(l1,PL);
        ll com_r = min(r1,PR);
        double nums = max((double)com_r-com_l+1,0.0);
        double p = nums / (PR-PL+1);

        com_l = max(l2,VL);
        com_r = min(r2,VR);
        nums = max((double)com_r-com_l+1,0.0);
        p *= nums / (VR-VL+1);

        ans += p;

        com_l = max(l1,VL);
        com_r = min(r1,VR);
        nums = max((double)com_r-com_l+1,0.0);
        p = nums / (VR-VL+1);

        com_l = max(l2,PL);
        com_r = min(r2,PR);
        nums = max((double)com_r-com_l+1,0.0);
        p *= nums / (PR-PL+1);

        ans += p;
    }

    cout << setprecision(15) << fixed << ans;
}

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <memory.h>
#include <sstream>

#define oo 1000000005
#define eps 1e-11

#define REP(i,n) for(int i = 0, _n = (n); i < _n; i++)
#define REPD(i,n) for(int i = (n) - 1; i >= 0; i--)
#define FOR(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define FOREACH(it,c) for (__typeof ((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define RESET(c,x) memset (c, x, sizeof (c))

#define sqr(x) ((x) * (x))
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(c) (c).begin(), (c).end()
#define SIZE(c) (c).size()

using namespace std;

struct point {
	double x,y;
	point (double x,double y): x(x),y(y) {}
	point () {x=y=0.0; }
	point operator +(point q) { return point(x+q.x,y+q.y); }
	point operator -(point q) { return point(x-q.x,y-q.y); }
	point operator *(double t) { return point(x*t,y*t); }
	point operator /(double t) { return point(x/t,y/t); }
	double operator *(point q){ return q.x * x + q.y * y; }
	double operator %(point q){ return x*q.y - y*q.x; }
//	int cmp(point q) const { if(int t = ::cmp(x,q.x)) return t; return ::cmp(y,q.y); }
//	#define Comp(x) bool operator x (point q) const { return cmp(q) x 0; }
//	Comp(>) Comp(<) Comp(==) Comp(>=) Comp(<=) Comp(!=)
//	#undef Comp
};

const double PI = 2.0 * acos (0.0);

typedef long long LL;
typedef pair <int, int> PII;

inline int getInt () { int x; scanf ("%d", &x); return x; }
inline LL getLL () { LL x; scanf ("%lld", &x); return x; };
inline int NUM (char c) { return (int)c - 48; }
inline char CHR (int n) { return (char)(n + 48); }
template <class T> inline T MAX (T a, T b) { if (a > b) return a; return b; }
template <class T> inline T MIN (T a, T b) { if (a < b) return a; return b; }

inline int BPM (int a, int b, int MOD) {
    if (a == 0)
        return 0;
    if (b == 0)
        return 1 % MOD;
    if (b % 2 == 1)
        return (int)((LL) BPM (a, b - 1, MOD) * a % MOD);
    int tmp = BPM (a, b / 2, MOD);
    return (int)((LL) tmp * tmp % MOD);
}

inline int phi (int N) {
    int ret = N;
    for (int i = 2; N > 1; i++) {
        if (i * i > N) {
            ret -= ret / N;
            break;
        }
        if ( N % i == 0 ) {
            ret -= ret / i;
            while (N % i == 0)
                N /= i;
        }
    }
    return ret;
}

inline void OPEN (string s) {
    freopen ((s + ".in").c_str (), "r", stdin);
    freopen ((s + ".out").c_str (), "w", stdout);
}

// ptrrsn_1's template

int N;

vector <int> v;

inline void generate_all_lucky() {
	FOR (p, 1, 9) {
		REP (bm, 1 << p) {
			int tmp = 0;
			REP (i, p) {
				if (bm & (1 << i)) {
					tmp = tmp * 10 + 4;
				} else {
					tmp = tmp * 10 + 7;
				}
			}
			v.PB(tmp);
		}
	}
}

int main () {
   // OPEN("B");
    int pl, pr, ql, qr;
    scanf("%d%d%d%d", &pl, &pr, &ql, &qr);
    int k;
    scanf("%d", &k);

    generate_all_lucky();
    sort(ALL(v));

    double ret = 0.0;
    REP (i, SIZE(v)) {
		if (i + k - 1 <= SIZE(v) - 1) {
			int a, b, c, d;
			int _p1, _p2, _q1, _q2;
			_p1 = pl;
			_p2 = pr;
			_q1 = ql;
			_q2 = qr;

			if (i - 1 < 0) a = 1;
			else a = v[i - 1] + 1;
			a = max(a, _p1);
			b = v[i];
			b = min(b, _p2);

			c = v[i + k - 1];
			c = max(c, _q1);
			if (i + 1 >= N) d = 1000000000;
			else d = v[i + 1] - 1;
			d = min(d, _q2);

			if (a <= b && c <= d) {
			//	cout << "hoi!" << endl;
			//	cout << a << " " << b << endl;
			//	cout << c << " " << d << endl;
				ret += 1. * (d - c + 1) / (_q2 - _q1 + 1) * (b - a + 1) / (_p2 - _p1 + 1);
			}

			_p1 = ql;
			_p2 = qr;
			_q1 = pl;
			_q2 = pr;

			if (i - 1 < 0) a = 1;
			else a = v[i - 1] + 1;
			a = max(a, _p1);
			b = v[i];
			b = min(b, _p2);

			c = v[i + k - 1];
			c = max(c, _q1);
			if (i + 1 >= N) d = 1000000000;
			else d = v[i + 1] - 1;
			d = min(d, _q2);

			if (a <= b && c <= d) {
			//	cout << "hoi!" << endl;
			//	cout << a << " " << b << endl;
			//	cout << c << " " << d << endl;
				ret += 1. * (d - c + 1) / (_q2 - _q1 + 1) * (b - a + 1) / (_p2 - _p1 + 1);
			}
		} else break;
	}

	printf("%.12lf\n", ret);

    return 0;
}

#include <iostream>
#include <stdio.h>
#include <algorithm>
#define oo 2000000000

using namespace std;

void initlucky();
class oPair{
	public:
		long a, b;
		oPair Bound(oPair x, oPair y){
			oPair res;
			res.a = min(x.a, y.a);
			res.b = max(x.b, y.b);
			return res;
		}
		oPair Intersect(oPair x, oPair y){
			oPair res;
			res.a = max(x.a, y.a);
			res.b = min(x.b, y.b);
			if (res.a > res.b) res.a = res.b = -1;
			return res;
		}
		long long Diff(){
			if (a == b && a == -1) return 0;
			else return (long long)(b - a + 1);
		}
		bool Contain(long n){
			return (n >= a && n <= b);
		}
};

oPair p1, p2;
long c, totallucky, lucky[1023];

void input(long &n){
	scanf("%ld", &n);
}

void input(oPair &p1, oPair &p2, long &c){
	input(p1.a); input(p1.b); input(p2.a); input(p2.b);
	input(c);
}

void GetLuckyList(oPair p, long a[], long &cnt){
	cnt = 0;
	for (long i = 0; i < totallucky; i++){
		if (p.Contain(lucky[i])) a[cnt++] = lucky[i];
	}
}

long long NumOfChoices(long left, long right, oPair pp){
	oPair p;
	p.a = left;
	p.b = right;
	p = p.Intersect(p, pp);
	return p.Diff();
}

long long calcNumOfCases(oPair p1, oPair p2, long leftLimit, long left, long right, long rightLimit){
	long long res = 0;
	// type1: min = p1, max = p2 -> leftLimit < p1 <= left < right <= p2 < rightLimit
	long long tmp1 = NumOfChoices(leftLimit + 1, left, p1);
	long long tmp2 = NumOfChoices(right, rightLimit - 1, p2);
	res += tmp1 * tmp2;

	tmp1 = NumOfChoices(leftLimit + 1, left, p2);
	tmp2 = NumOfChoices(right, rightLimit - 1, p1);
	res += tmp1 * tmp2;
	return res;
}

long lstNums[1023];

float solve(oPair p1, oPair p2, long c){
	oPair pInt = p1.Bound(p1, p2);
	long long totalcases = p1.Diff() * p2.Diff();
	long long numofcases = 0;
	long luckCount;
	GetLuckyList(pInt, lstNums, luckCount);
	sort(lstNums, lstNums + luckCount);
	for (long left = 0; left < luckCount; left++){
		long right = left + c - 1;
		if (right >= luckCount) break;
		// calculate numbers of pair contains lstNums[left] to lstNums[right]
		numofcases += calcNumOfCases(p1, p2, (left == 0 ? -1:lstNums[left - 1]), lstNums[left], lstNums[right], right == luckCount - 1? oo:lstNums[right + 1]);
	}
	return (float)numofcases / totalcases;
}

void output(float res){
	printf("%.9lf", res);
}

main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	initlucky();
	input(p1, p2, c);
	float res = solve(p1, p2, c);
	output(res);
}

void initlucky(){
   lucky[1] = 4;
   lucky[2] = 44;
   lucky[3] = 444;
   lucky[4] = 4444;
   lucky[5] = 44444;
   lucky[6] = 444444;
   lucky[7] = 4444444;
   lucky[8] = 44444444;
   lucky[9] = 444444444;
   lucky[10] = 444444447;
   lucky[11] = 44444447;
   lucky[12] = 444444474;
   lucky[13] = 444444477;
   lucky[14] = 4444447;
   lucky[15] = 44444474;
   lucky[16] = 444444744;
   lucky[17] = 444444747;
   lucky[18] = 44444477;
   lucky[19] = 444444774;
   lucky[20] = 444444777;
   lucky[21] = 444447;
   lucky[22] = 4444474;
   lucky[23] = 44444744;
   lucky[24] = 444447444;
   lucky[25] = 444447447;
   lucky[26] = 44444747;
   lucky[27] = 444447474;
   lucky[28] = 444447477;
   lucky[29] = 4444477;
   lucky[30] = 44444774;
   lucky[31] = 444447744;
   lucky[32] = 444447747;
   lucky[33] = 44444777;
   lucky[34] = 444447774;
   lucky[35] = 444447777;
   lucky[36] = 44447;
   lucky[37] = 444474;
   lucky[38] = 4444744;
   lucky[39] = 44447444;
   lucky[40] = 444474444;
   lucky[41] = 444474447;
   lucky[42] = 44447447;
   lucky[43] = 444474474;
   lucky[44] = 444474477;
   lucky[45] = 4444747;
   lucky[46] = 44447474;
   lucky[47] = 444474744;
   lucky[48] = 444474747;
   lucky[49] = 44447477;
   lucky[50] = 444474774;
   lucky[51] = 444474777;
   lucky[52] = 444477;
   lucky[53] = 4444774;
   lucky[54] = 44447744;
   lucky[55] = 444477444;
   lucky[56] = 444477447;
   lucky[57] = 44447747;
   lucky[58] = 444477474;
   lucky[59] = 444477477;
   lucky[60] = 4444777;
   lucky[61] = 44447774;
   lucky[62] = 444477744;
   lucky[63] = 444477747;
   lucky[64] = 44447777;
   lucky[65] = 444477774;
   lucky[66] = 444477777;
   lucky[67] = 4447;
   lucky[68] = 44474;
   lucky[69] = 444744;
   lucky[70] = 4447444;
   lucky[71] = 44474444;
   lucky[72] = 444744444;
   lucky[73] = 444744447;
   lucky[74] = 44474447;
   lucky[75] = 444744474;
   lucky[76] = 444744477;
   lucky[77] = 4447447;
   lucky[78] = 44474474;
   lucky[79] = 444744744;
   lucky[80] = 444744747;
   lucky[81] = 44474477;
   lucky[82] = 444744774;
   lucky[83] = 444744777;
   lucky[84] = 444747;
   lucky[85] = 4447474;
   lucky[86] = 44474744;
   lucky[87] = 444747444;
   lucky[88] = 444747447;
   lucky[89] = 44474747;
   lucky[90] = 444747474;
   lucky[91] = 444747477;
   lucky[92] = 4447477;
   lucky[93] = 44474774;
   lucky[94] = 444747744;
   lucky[95] = 444747747;
   lucky[96] = 44474777;
   lucky[97] = 444747774;
   lucky[98] = 444747777;
   lucky[99] = 44477;
   lucky[100] = 444774;
   lucky[101] = 4447744;
   lucky[102] = 44477444;
   lucky[103] = 444774444;
   lucky[104] = 444774447;
   lucky[105] = 44477447;
   lucky[106] = 444774474;
   lucky[107] = 444774477;
   lucky[108] = 4447747;
   lucky[109] = 44477474;
   lucky[110] = 444774744;
   lucky[111] = 444774747;
   lucky[112] = 44477477;
   lucky[113] = 444774774;
   lucky[114] = 444774777;
   lucky[115] = 444777;
   lucky[116] = 4447774;
   lucky[117] = 44477744;
   lucky[118] = 444777444;
   lucky[119] = 444777447;
   lucky[120] = 44477747;
   lucky[121] = 444777474;
   lucky[122] = 444777477;
   lucky[123] = 4447777;
   lucky[124] = 44477774;
   lucky[125] = 444777744;
   lucky[126] = 444777747;
   lucky[127] = 44477777;
   lucky[128] = 444777774;
   lucky[129] = 444777777;
   lucky[130] = 447;
   lucky[131] = 4474;
   lucky[132] = 44744;
   lucky[133] = 447444;
   lucky[134] = 4474444;
   lucky[135] = 44744444;
   lucky[136] = 447444444;
   lucky[137] = 447444447;
   lucky[138] = 44744447;
   lucky[139] = 447444474;
   lucky[140] = 447444477;
   lucky[141] = 4474447;
   lucky[142] = 44744474;
   lucky[143] = 447444744;
   lucky[144] = 447444747;
   lucky[145] = 44744477;
   lucky[146] = 447444774;
   lucky[147] = 447444777;
   lucky[148] = 447447;
   lucky[149] = 4474474;
   lucky[150] = 44744744;
   lucky[151] = 447447444;
   lucky[152] = 447447447;
   lucky[153] = 44744747;
   lucky[154] = 447447474;
   lucky[155] = 447447477;
   lucky[156] = 4474477;
   lucky[157] = 44744774;
   lucky[158] = 447447744;
   lucky[159] = 447447747;
   lucky[160] = 44744777;
   lucky[161] = 447447774;
   lucky[162] = 447447777;
   lucky[163] = 44747;
   lucky[164] = 447474;
   lucky[165] = 4474744;
   lucky[166] = 44747444;
   lucky[167] = 447474444;
   lucky[168] = 447474447;
   lucky[169] = 44747447;
   lucky[170] = 447474474;
   lucky[171] = 447474477;
   lucky[172] = 4474747;
   lucky[173] = 44747474;
   lucky[174] = 447474744;
   lucky[175] = 447474747;
   lucky[176] = 44747477;
   lucky[177] = 447474774;
   lucky[178] = 447474777;
   lucky[179] = 447477;
   lucky[180] = 4474774;
   lucky[181] = 44747744;
   lucky[182] = 447477444;
   lucky[183] = 447477447;
   lucky[184] = 44747747;
   lucky[185] = 447477474;
   lucky[186] = 447477477;
   lucky[187] = 4474777;
   lucky[188] = 44747774;
   lucky[189] = 447477744;
   lucky[190] = 447477747;
   lucky[191] = 44747777;
   lucky[192] = 447477774;
   lucky[193] = 447477777;
   lucky[194] = 4477;
   lucky[195] = 44774;
   lucky[196] = 447744;
   lucky[197] = 4477444;
   lucky[198] = 44774444;
   lucky[199] = 447744444;
   lucky[200] = 447744447;
   lucky[201] = 44774447;
   lucky[202] = 447744474;
   lucky[203] = 447744477;
   lucky[204] = 4477447;
   lucky[205] = 44774474;
   lucky[206] = 447744744;
   lucky[207] = 447744747;
   lucky[208] = 44774477;
   lucky[209] = 447744774;
   lucky[210] = 447744777;
   lucky[211] = 447747;
   lucky[212] = 4477474;
   lucky[213] = 44774744;
   lucky[214] = 447747444;
   lucky[215] = 447747447;
   lucky[216] = 44774747;
   lucky[217] = 447747474;
   lucky[218] = 447747477;
   lucky[219] = 4477477;
   lucky[220] = 44774774;
   lucky[221] = 447747744;
   lucky[222] = 447747747;
   lucky[223] = 44774777;
   lucky[224] = 447747774;
   lucky[225] = 447747777;
   lucky[226] = 44777;
   lucky[227] = 447774;
   lucky[228] = 4477744;
   lucky[229] = 44777444;
   lucky[230] = 447774444;
   lucky[231] = 447774447;
   lucky[232] = 44777447;
   lucky[233] = 447774474;
   lucky[234] = 447774477;
   lucky[235] = 4477747;
   lucky[236] = 44777474;
   lucky[237] = 447774744;
   lucky[238] = 447774747;
   lucky[239] = 44777477;
   lucky[240] = 447774774;
   lucky[241] = 447774777;
   lucky[242] = 447777;
   lucky[243] = 4477774;
   lucky[244] = 44777744;
   lucky[245] = 447777444;
   lucky[246] = 447777447;
   lucky[247] = 44777747;
   lucky[248] = 447777474;
   lucky[249] = 447777477;
   lucky[250] = 4477777;
   lucky[251] = 44777774;
   lucky[252] = 447777744;
   lucky[253] = 447777747;
   lucky[254] = 44777777;
   lucky[255] = 447777774;
   lucky[256] = 447777777;
   lucky[257] = 47;
   lucky[258] = 474;
   lucky[259] = 4744;
   lucky[260] = 47444;
   lucky[261] = 474444;
   lucky[262] = 4744444;
   lucky[263] = 47444444;
   lucky[264] = 474444444;
   lucky[265] = 474444447;
   lucky[266] = 47444447;
   lucky[267] = 474444474;
   lucky[268] = 474444477;
   lucky[269] = 4744447;
   lucky[270] = 47444474;
   lucky[271] = 474444744;
   lucky[272] = 474444747;
   lucky[273] = 47444477;
   lucky[274] = 474444774;
   lucky[275] = 474444777;
   lucky[276] = 474447;
   lucky[277] = 4744474;
   lucky[278] = 47444744;
   lucky[279] = 474447444;
   lucky[280] = 474447447;
   lucky[281] = 47444747;
   lucky[282] = 474447474;
   lucky[283] = 474447477;
   lucky[284] = 4744477;
   lucky[285] = 47444774;
   lucky[286] = 474447744;
   lucky[287] = 474447747;
   lucky[288] = 47444777;
   lucky[289] = 474447774;
   lucky[290] = 474447777;
   lucky[291] = 47447;
   lucky[292] = 474474;
   lucky[293] = 4744744;
   lucky[294] = 47447444;
   lucky[295] = 474474444;
   lucky[296] = 474474447;
   lucky[297] = 47447447;
   lucky[298] = 474474474;
   lucky[299] = 474474477;
   lucky[300] = 4744747;
   lucky[301] = 47447474;
   lucky[302] = 474474744;
   lucky[303] = 474474747;
   lucky[304] = 47447477;
   lucky[305] = 474474774;
   lucky[306] = 474474777;
   lucky[307] = 474477;
   lucky[308] = 4744774;
   lucky[309] = 47447744;
   lucky[310] = 474477444;
   lucky[311] = 474477447;
   lucky[312] = 47447747;
   lucky[313] = 474477474;
   lucky[314] = 474477477;
   lucky[315] = 4744777;
   lucky[316] = 47447774;
   lucky[317] = 474477744;
   lucky[318] = 474477747;
   lucky[319] = 47447777;
   lucky[320] = 474477774;
   lucky[321] = 474477777;
   lucky[322] = 4747;
   lucky[323] = 47474;
   lucky[324] = 474744;
   lucky[325] = 4747444;
   lucky[326] = 47474444;
   lucky[327] = 474744444;
   lucky[328] = 474744447;
   lucky[329] = 47474447;
   lucky[330] = 474744474;
   lucky[331] = 474744477;
   lucky[332] = 4747447;
   lucky[333] = 47474474;
   lucky[334] = 474744744;
   lucky[335] = 474744747;
   lucky[336] = 47474477;
   lucky[337] = 474744774;
   lucky[338] = 474744777;
   lucky[339] = 474747;
   lucky[340] = 4747474;
   lucky[341] = 47474744;
   lucky[342] = 474747444;
   lucky[343] = 474747447;
   lucky[344] = 47474747;
   lucky[345] = 474747474;
   lucky[346] = 474747477;
   lucky[347] = 4747477;
   lucky[348] = 47474774;
   lucky[349] = 474747744;
   lucky[350] = 474747747;
   lucky[351] = 47474777;
   lucky[352] = 474747774;
   lucky[353] = 474747777;
   lucky[354] = 47477;
   lucky[355] = 474774;
   lucky[356] = 4747744;
   lucky[357] = 47477444;
   lucky[358] = 474774444;
   lucky[359] = 474774447;
   lucky[360] = 47477447;
   lucky[361] = 474774474;
   lucky[362] = 474774477;
   lucky[363] = 4747747;
   lucky[364] = 47477474;
   lucky[365] = 474774744;
   lucky[366] = 474774747;
   lucky[367] = 47477477;
   lucky[368] = 474774774;
   lucky[369] = 474774777;
   lucky[370] = 474777;
   lucky[371] = 4747774;
   lucky[372] = 47477744;
   lucky[373] = 474777444;
   lucky[374] = 474777447;
   lucky[375] = 47477747;
   lucky[376] = 474777474;
   lucky[377] = 474777477;
   lucky[378] = 4747777;
   lucky[379] = 47477774;
   lucky[380] = 474777744;
   lucky[381] = 474777747;
   lucky[382] = 47477777;
   lucky[383] = 474777774;
   lucky[384] = 474777777;
   lucky[385] = 477;
   lucky[386] = 4774;
   lucky[387] = 47744;
   lucky[388] = 477444;
   lucky[389] = 4774444;
   lucky[390] = 47744444;
   lucky[391] = 477444444;
   lucky[392] = 477444447;
   lucky[393] = 47744447;
   lucky[394] = 477444474;
   lucky[395] = 477444477;
   lucky[396] = 4774447;
   lucky[397] = 47744474;
   lucky[398] = 477444744;
   lucky[399] = 477444747;
   lucky[400] = 47744477;
   lucky[401] = 477444774;
   lucky[402] = 477444777;
   lucky[403] = 477447;
   lucky[404] = 4774474;
   lucky[405] = 47744744;
   lucky[406] = 477447444;
   lucky[407] = 477447447;
   lucky[408] = 47744747;
   lucky[409] = 477447474;
   lucky[410] = 477447477;
   lucky[411] = 4774477;
   lucky[412] = 47744774;
   lucky[413] = 477447744;
   lucky[414] = 477447747;
   lucky[415] = 47744777;
   lucky[416] = 477447774;
   lucky[417] = 477447777;
   lucky[418] = 47747;
   lucky[419] = 477474;
   lucky[420] = 4774744;
   lucky[421] = 47747444;
   lucky[422] = 477474444;
   lucky[423] = 477474447;
   lucky[424] = 47747447;
   lucky[425] = 477474474;
   lucky[426] = 477474477;
   lucky[427] = 4774747;
   lucky[428] = 47747474;
   lucky[429] = 477474744;
   lucky[430] = 477474747;
   lucky[431] = 47747477;
   lucky[432] = 477474774;
   lucky[433] = 477474777;
   lucky[434] = 477477;
   lucky[435] = 4774774;
   lucky[436] = 47747744;
   lucky[437] = 477477444;
   lucky[438] = 477477447;
   lucky[439] = 47747747;
   lucky[440] = 477477474;
   lucky[441] = 477477477;
   lucky[442] = 4774777;
   lucky[443] = 47747774;
   lucky[444] = 477477744;
   lucky[445] = 477477747;
   lucky[446] = 47747777;
   lucky[447] = 477477774;
   lucky[448] = 477477777;
   lucky[449] = 4777;
   lucky[450] = 47774;
   lucky[451] = 477744;
   lucky[452] = 4777444;
   lucky[453] = 47774444;
   lucky[454] = 477744444;
   lucky[455] = 477744447;
   lucky[456] = 47774447;
   lucky[457] = 477744474;
   lucky[458] = 477744477;
   lucky[459] = 4777447;
   lucky[460] = 47774474;
   lucky[461] = 477744744;
   lucky[462] = 477744747;
   lucky[463] = 47774477;
   lucky[464] = 477744774;
   lucky[465] = 477744777;
   lucky[466] = 477747;
   lucky[467] = 4777474;
   lucky[468] = 47774744;
   lucky[469] = 477747444;
   lucky[470] = 477747447;
   lucky[471] = 47774747;
   lucky[472] = 477747474;
   lucky[473] = 477747477;
   lucky[474] = 4777477;
   lucky[475] = 47774774;
   lucky[476] = 477747744;
   lucky[477] = 477747747;
   lucky[478] = 47774777;
   lucky[479] = 477747774;
   lucky[480] = 477747777;
   lucky[481] = 47777;
   lucky[482] = 477774;
   lucky[483] = 4777744;
   lucky[484] = 47777444;
   lucky[485] = 477774444;
   lucky[486] = 477774447;
   lucky[487] = 47777447;
   lucky[488] = 477774474;
   lucky[489] = 477774477;
   lucky[490] = 4777747;
   lucky[491] = 47777474;
   lucky[492] = 477774744;
   lucky[493] = 477774747;
   lucky[494] = 47777477;
   lucky[495] = 477774774;
   lucky[496] = 477774777;
   lucky[497] = 477777;
   lucky[498] = 4777774;
   lucky[499] = 47777744;
   lucky[500] = 477777444;
   lucky[501] = 477777447;
   lucky[502] = 47777747;
   lucky[503] = 477777474;
   lucky[504] = 477777477;
   lucky[505] = 4777777;
   lucky[506] = 47777774;
   lucky[507] = 477777744;
   lucky[508] = 477777747;
   lucky[509] = 47777777;
   lucky[510] = 477777774;
   lucky[511] = 477777777;
   lucky[512] = 7;
   lucky[513] = 74;
   lucky[514] = 744;
   lucky[515] = 7444;
   lucky[516] = 74444;
   lucky[517] = 744444;
   lucky[518] = 7444444;
   lucky[519] = 74444444;
   lucky[520] = 744444444;
   lucky[521] = 744444447;
   lucky[522] = 74444447;
   lucky[523] = 744444474;
   lucky[524] = 744444477;
   lucky[525] = 7444447;
   lucky[526] = 74444474;
   lucky[527] = 744444744;
   lucky[528] = 744444747;
   lucky[529] = 74444477;
   lucky[530] = 744444774;
   lucky[531] = 744444777;
   lucky[532] = 744447;
   lucky[533] = 7444474;
   lucky[534] = 74444744;
   lucky[535] = 744447444;
   lucky[536] = 744447447;
   lucky[537] = 74444747;
   lucky[538] = 744447474;
   lucky[539] = 744447477;
   lucky[540] = 7444477;
   lucky[541] = 74444774;
   lucky[542] = 744447744;
   lucky[543] = 744447747;
   lucky[544] = 74444777;
   lucky[545] = 744447774;
   lucky[546] = 744447777;
   lucky[547] = 74447;
   lucky[548] = 744474;
   lucky[549] = 7444744;
   lucky[550] = 74447444;
   lucky[551] = 744474444;
   lucky[552] = 744474447;
   lucky[553] = 74447447;
   lucky[554] = 744474474;
   lucky[555] = 744474477;
   lucky[556] = 7444747;
   lucky[557] = 74447474;
   lucky[558] = 744474744;
   lucky[559] = 744474747;
   lucky[560] = 74447477;
   lucky[561] = 744474774;
   lucky[562] = 744474777;
   lucky[563] = 744477;
   lucky[564] = 7444774;
   lucky[565] = 74447744;
   lucky[566] = 744477444;
   lucky[567] = 744477447;
   lucky[568] = 74447747;
   lucky[569] = 744477474;
   lucky[570] = 744477477;
   lucky[571] = 7444777;
   lucky[572] = 74447774;
   lucky[573] = 744477744;
   lucky[574] = 744477747;
   lucky[575] = 74447777;
   lucky[576] = 744477774;
   lucky[577] = 744477777;
   lucky[578] = 7447;
   lucky[579] = 74474;
   lucky[580] = 744744;
   lucky[581] = 7447444;
   lucky[582] = 74474444;
   lucky[583] = 744744444;
   lucky[584] = 744744447;
   lucky[585] = 74474447;
   lucky[586] = 744744474;
   lucky[587] = 744744477;
   lucky[588] = 7447447;
   lucky[589] = 74474474;
   lucky[590] = 744744744;
   lucky[591] = 744744747;
   lucky[592] = 74474477;
   lucky[593] = 744744774;
   lucky[594] = 744744777;
   lucky[595] = 744747;
   lucky[596] = 7447474;
   lucky[597] = 74474744;
   lucky[598] = 744747444;
   lucky[599] = 744747447;
   lucky[600] = 74474747;
   lucky[601] = 744747474;
   lucky[602] = 744747477;
   lucky[603] = 7447477;
   lucky[604] = 74474774;
   lucky[605] = 744747744;
   lucky[606] = 744747747;
   lucky[607] = 74474777;
   lucky[608] = 744747774;
   lucky[609] = 744747777;
   lucky[610] = 74477;
   lucky[611] = 744774;
   lucky[612] = 7447744;
   lucky[613] = 74477444;
   lucky[614] = 744774444;
   lucky[615] = 744774447;
   lucky[616] = 74477447;
   lucky[617] = 744774474;
   lucky[618] = 744774477;
   lucky[619] = 7447747;
   lucky[620] = 74477474;
   lucky[621] = 744774744;
   lucky[622] = 744774747;
   lucky[623] = 74477477;
   lucky[624] = 744774774;
   lucky[625] = 744774777;
   lucky[626] = 744777;
   lucky[627] = 7447774;
   lucky[628] = 74477744;
   lucky[629] = 744777444;
   lucky[630] = 744777447;
   lucky[631] = 74477747;
   lucky[632] = 744777474;
   lucky[633] = 744777477;
   lucky[634] = 7447777;
   lucky[635] = 74477774;
   lucky[636] = 744777744;
   lucky[637] = 744777747;
   lucky[638] = 74477777;
   lucky[639] = 744777774;
   lucky[640] = 744777777;
   lucky[641] = 747;
   lucky[642] = 7474;
   lucky[643] = 74744;
   lucky[644] = 747444;
   lucky[645] = 7474444;
   lucky[646] = 74744444;
   lucky[647] = 747444444;
   lucky[648] = 747444447;
   lucky[649] = 74744447;
   lucky[650] = 747444474;
   lucky[651] = 747444477;
   lucky[652] = 7474447;
   lucky[653] = 74744474;
   lucky[654] = 747444744;
   lucky[655] = 747444747;
   lucky[656] = 74744477;
   lucky[657] = 747444774;
   lucky[658] = 747444777;
   lucky[659] = 747447;
   lucky[660] = 7474474;
   lucky[661] = 74744744;
   lucky[662] = 747447444;
   lucky[663] = 747447447;
   lucky[664] = 74744747;
   lucky[665] = 747447474;
   lucky[666] = 747447477;
   lucky[667] = 7474477;
   lucky[668] = 74744774;
   lucky[669] = 747447744;
   lucky[670] = 747447747;
   lucky[671] = 74744777;
   lucky[672] = 747447774;
   lucky[673] = 747447777;
   lucky[674] = 74747;
   lucky[675] = 747474;
   lucky[676] = 7474744;
   lucky[677] = 74747444;
   lucky[678] = 747474444;
   lucky[679] = 747474447;
   lucky[680] = 74747447;
   lucky[681] = 747474474;
   lucky[682] = 747474477;
   lucky[683] = 7474747;
   lucky[684] = 74747474;
   lucky[685] = 747474744;
   lucky[686] = 747474747;
   lucky[687] = 74747477;
   lucky[688] = 747474774;
   lucky[689] = 747474777;
   lucky[690] = 747477;
   lucky[691] = 7474774;
   lucky[692] = 74747744;
   lucky[693] = 747477444;
   lucky[694] = 747477447;
   lucky[695] = 74747747;
   lucky[696] = 747477474;
   lucky[697] = 747477477;
   lucky[698] = 7474777;
   lucky[699] = 74747774;
   lucky[700] = 747477744;
   lucky[701] = 747477747;
   lucky[702] = 74747777;
   lucky[703] = 747477774;
   lucky[704] = 747477777;
   lucky[705] = 7477;
   lucky[706] = 74774;
   lucky[707] = 747744;
   lucky[708] = 7477444;
   lucky[709] = 74774444;
   lucky[710] = 747744444;
   lucky[711] = 747744447;
   lucky[712] = 74774447;
   lucky[713] = 747744474;
   lucky[714] = 747744477;
   lucky[715] = 7477447;
   lucky[716] = 74774474;
   lucky[717] = 747744744;
   lucky[718] = 747744747;
   lucky[719] = 74774477;
   lucky[720] = 747744774;
   lucky[721] = 747744777;
   lucky[722] = 747747;
   lucky[723] = 7477474;
   lucky[724] = 74774744;
   lucky[725] = 747747444;
   lucky[726] = 747747447;
   lucky[727] = 74774747;
   lucky[728] = 747747474;
   lucky[729] = 747747477;
   lucky[730] = 7477477;
   lucky[731] = 74774774;
   lucky[732] = 747747744;
   lucky[733] = 747747747;
   lucky[734] = 74774777;
   lucky[735] = 747747774;
   lucky[736] = 747747777;
   lucky[737] = 74777;
   lucky[738] = 747774;
   lucky[739] = 7477744;
   lucky[740] = 74777444;
   lucky[741] = 747774444;
   lucky[742] = 747774447;
   lucky[743] = 74777447;
   lucky[744] = 747774474;
   lucky[745] = 747774477;
   lucky[746] = 7477747;
   lucky[747] = 74777474;
   lucky[748] = 747774744;
   lucky[749] = 747774747;
   lucky[750] = 74777477;
   lucky[751] = 747774774;
   lucky[752] = 747774777;
   lucky[753] = 747777;
   lucky[754] = 7477774;
   lucky[755] = 74777744;
   lucky[756] = 747777444;
   lucky[757] = 747777447;
   lucky[758] = 74777747;
   lucky[759] = 747777474;
   lucky[760] = 747777477;
   lucky[761] = 7477777;
   lucky[762] = 74777774;
   lucky[763] = 747777744;
   lucky[764] = 747777747;
   lucky[765] = 74777777;
   lucky[766] = 747777774;
   lucky[767] = 747777777;
   lucky[768] = 77;
   lucky[769] = 774;
   lucky[770] = 7744;
   lucky[771] = 77444;
   lucky[772] = 774444;
   lucky[773] = 7744444;
   lucky[774] = 77444444;
   lucky[775] = 774444444;
   lucky[776] = 774444447;
   lucky[777] = 77444447;
   lucky[778] = 774444474;
   lucky[779] = 774444477;
   lucky[780] = 7744447;
   lucky[781] = 77444474;
   lucky[782] = 774444744;
   lucky[783] = 774444747;
   lucky[784] = 77444477;
   lucky[785] = 774444774;
   lucky[786] = 774444777;
   lucky[787] = 774447;
   lucky[788] = 7744474;
   lucky[789] = 77444744;
   lucky[790] = 774447444;
   lucky[791] = 774447447;
   lucky[792] = 77444747;
   lucky[793] = 774447474;
   lucky[794] = 774447477;
   lucky[795] = 7744477;
   lucky[796] = 77444774;
   lucky[797] = 774447744;
   lucky[798] = 774447747;
   lucky[799] = 77444777;
   lucky[800] = 774447774;
   lucky[801] = 774447777;
   lucky[802] = 77447;
   lucky[803] = 774474;
   lucky[804] = 7744744;
   lucky[805] = 77447444;
   lucky[806] = 774474444;
   lucky[807] = 774474447;
   lucky[808] = 77447447;
   lucky[809] = 774474474;
   lucky[810] = 774474477;
   lucky[811] = 7744747;
   lucky[812] = 77447474;
   lucky[813] = 774474744;
   lucky[814] = 774474747;
   lucky[815] = 77447477;
   lucky[816] = 774474774;
   lucky[817] = 774474777;
   lucky[818] = 774477;
   lucky[819] = 7744774;
   lucky[820] = 77447744;
   lucky[821] = 774477444;
   lucky[822] = 774477447;
   lucky[823] = 77447747;
   lucky[824] = 774477474;
   lucky[825] = 774477477;
   lucky[826] = 7744777;
   lucky[827] = 77447774;
   lucky[828] = 774477744;
   lucky[829] = 774477747;
   lucky[830] = 77447777;
   lucky[831] = 774477774;
   lucky[832] = 774477777;
   lucky[833] = 7747;
   lucky[834] = 77474;
   lucky[835] = 774744;
   lucky[836] = 7747444;
   lucky[837] = 77474444;
   lucky[838] = 774744444;
   lucky[839] = 774744447;
   lucky[840] = 77474447;
   lucky[841] = 774744474;
   lucky[842] = 774744477;
   lucky[843] = 7747447;
   lucky[844] = 77474474;
   lucky[845] = 774744744;
   lucky[846] = 774744747;
   lucky[847] = 77474477;
   lucky[848] = 774744774;
   lucky[849] = 774744777;
   lucky[850] = 774747;
   lucky[851] = 7747474;
   lucky[852] = 77474744;
   lucky[853] = 774747444;
   lucky[854] = 774747447;
   lucky[855] = 77474747;
   lucky[856] = 774747474;
   lucky[857] = 774747477;
   lucky[858] = 7747477;
   lucky[859] = 77474774;
   lucky[860] = 774747744;
   lucky[861] = 774747747;
   lucky[862] = 77474777;
   lucky[863] = 774747774;
   lucky[864] = 774747777;
   lucky[865] = 77477;
   lucky[866] = 774774;
   lucky[867] = 7747744;
   lucky[868] = 77477444;
   lucky[869] = 774774444;
   lucky[870] = 774774447;
   lucky[871] = 77477447;
   lucky[872] = 774774474;
   lucky[873] = 774774477;
   lucky[874] = 7747747;
   lucky[875] = 77477474;
   lucky[876] = 774774744;
   lucky[877] = 774774747;
   lucky[878] = 77477477;
   lucky[879] = 774774774;
   lucky[880] = 774774777;
   lucky[881] = 774777;
   lucky[882] = 7747774;
   lucky[883] = 77477744;
   lucky[884] = 774777444;
   lucky[885] = 774777447;
   lucky[886] = 77477747;
   lucky[887] = 774777474;
   lucky[888] = 774777477;
   lucky[889] = 7747777;
   lucky[890] = 77477774;
   lucky[891] = 774777744;
   lucky[892] = 774777747;
   lucky[893] = 77477777;
   lucky[894] = 774777774;
   lucky[895] = 774777777;
   lucky[896] = 777;
   lucky[897] = 7774;
   lucky[898] = 77744;
   lucky[899] = 777444;
   lucky[900] = 7774444;
   lucky[901] = 77744444;
   lucky[902] = 777444444;
   lucky[903] = 777444447;
   lucky[904] = 77744447;
   lucky[905] = 777444474;
   lucky[906] = 777444477;
   lucky[907] = 7774447;
   lucky[908] = 77744474;
   lucky[909] = 777444744;
   lucky[910] = 777444747;
   lucky[911] = 77744477;
   lucky[912] = 777444774;
   lucky[913] = 777444777;
   lucky[914] = 777447;
   lucky[915] = 7774474;
   lucky[916] = 77744744;
   lucky[917] = 777447444;
   lucky[918] = 777447447;
   lucky[919] = 77744747;
   lucky[920] = 777447474;
   lucky[921] = 777447477;
   lucky[922] = 7774477;
   lucky[923] = 77744774;
   lucky[924] = 777447744;
   lucky[925] = 777447747;
   lucky[926] = 77744777;
   lucky[927] = 777447774;
   lucky[928] = 777447777;
   lucky[929] = 77747;
   lucky[930] = 777474;
   lucky[931] = 7774744;
   lucky[932] = 77747444;
   lucky[933] = 777474444;
   lucky[934] = 777474447;
   lucky[935] = 77747447;
   lucky[936] = 777474474;
   lucky[937] = 777474477;
   lucky[938] = 7774747;
   lucky[939] = 77747474;
   lucky[940] = 777474744;
   lucky[941] = 777474747;
   lucky[942] = 77747477;
   lucky[943] = 777474774;
   lucky[944] = 777474777;
   lucky[945] = 777477;
   lucky[946] = 7774774;
   lucky[947] = 77747744;
   lucky[948] = 777477444;
   lucky[949] = 777477447;
   lucky[950] = 77747747;
   lucky[951] = 777477474;
   lucky[952] = 777477477;
   lucky[953] = 7774777;
   lucky[954] = 77747774;
   lucky[955] = 777477744;
   lucky[956] = 777477747;
   lucky[957] = 77747777;
   lucky[958] = 777477774;
   lucky[959] = 777477777;
   lucky[960] = 7777;
   lucky[961] = 77774;
   lucky[962] = 777744;
   lucky[963] = 7777444;
   lucky[964] = 77774444;
   lucky[965] = 777744444;
   lucky[966] = 777744447;
   lucky[967] = 77774447;
   lucky[968] = 777744474;
   lucky[969] = 777744477;
   lucky[970] = 7777447;
   lucky[971] = 77774474;
   lucky[972] = 777744744;
   lucky[973] = 777744747;
   lucky[974] = 77774477;
   lucky[975] = 777744774;
   lucky[976] = 777744777;
   lucky[977] = 777747;
   lucky[978] = 7777474;
   lucky[979] = 77774744;
   lucky[980] = 777747444;
   lucky[981] = 777747447;
   lucky[982] = 77774747;
   lucky[983] = 777747474;
   lucky[984] = 777747477;
   lucky[985] = 7777477;
   lucky[986] = 77774774;
   lucky[987] = 777747744;
   lucky[988] = 777747747;
   lucky[989] = 77774777;
   lucky[990] = 777747774;
   lucky[991] = 777747777;
   lucky[992] = 77777;
   lucky[993] = 777774;
   lucky[994] = 7777744;
   lucky[995] = 77777444;
   lucky[996] = 777774444;
   lucky[997] = 777774447;
   lucky[998] = 77777447;
   lucky[999] = 777774474;
   lucky[1000] = 777774477;
   lucky[1001] = 7777747;
   lucky[1002] = 77777474;
   lucky[1003] = 777774744;
   lucky[1004] = 777774747;
   lucky[1005] = 77777477;
   lucky[1006] = 777774774;
   lucky[1007] = 777774777;
   lucky[1008] = 777777;
   lucky[1009] = 7777774;
   lucky[1010] = 77777744;
   lucky[1011] = 777777444;
   lucky[1012] = 777777447;
   lucky[1013] = 77777747;
   lucky[1014] = 777777474;
   lucky[1015] = 777777477;
   lucky[1016] = 7777777;
   lucky[1017] = 77777774;
   lucky[1018] = 777777744;
   lucky[1019] = 777777747;
   lucky[1020] = 77777777;
   lucky[1021] = 777777774;
   lucky[1022] = 777777777;
	totallucky = 1023;
}

#include <bits/stdc++.h>
using namespace std;
#define limite 1000000000LL
typedef long long int LL;
vector<LL> v;
void dfs(LL n) {
    v.push_back(n);
    if( n * 10LL + 4LL < limite ) dfs(n * 10LL + 4LL);
    if( n * 10LL + 7LL < limite ) dfs(n * 10LL + 7LL);
}
LL f(pair<LL, LL> rango, LL a, LL b) {
    if( rango.second < a || b < rango.first ) return 0LL;
    if( rango.first <= a && b <= rango.second ) return b - a + 1LL;
    if( a <= rango.first && rango.second <= b ) return rango.second - rango.first + 1LL;
    if( rango.first >= a ) return b - rango.first + 1LL;
    return rango.second - a + 1LL;
}
int main() {
    dfs(4); dfs(7);
    int sz = v.size();
    v.push_back(1);
    v.push_back(limite);
    sort(v.begin(), v.end());
    pair<LL, LL> a, b;
    LL cnt, sum = 0LL;
    cin>>a.first>>a.second>>b.first>>b.second>>cnt;
    for(int i=1 ; i<sz && i+cnt<=sz ; i++) {
        LL tmpA = f(a, v[i - 1], v[i]);
        LL tmpB = f(b, v[i + cnt - 1], v[i + cnt]);
        sum += tmpA * tmpB;
        tmpA = f(b, v[i - 1], v[i]);
        tmpB = f(a, v[i + cnt - 1], v[i + cnt]);
        sum += tmpA * tmpB;
    }
    LL lenA = a.second - a.first + 1LL;
    LL lenB = b.second - b.first + 1LL;
    printf("%.12lf\n", (double)sum / (lenA * lenB) );
    return 0;
}

#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,x,n) for (int i = x;i < n;++i)

set<int> st;

void go(ll x) {
	if (x >= 1e9)return;
	st.insert(x);
	go(x * 10 + 4);
	go(x * 10 + 7);
}

int main() {
	int l1, l2, r1, r2, k;
	scanf("%d%d%d%d%d", &l1, &r1, &l2, &r2, &k);
	int s1 = r1 - l1 + 1, s2 = r2 - l2 + 1;
	go(4), go(7);
	st.insert(0);
	int c = 0;
	long double an = 0.0;
	set<int>::iterator it = st.begin(), it0 = st.begin();
	while (it != st.end() && c != k)++it, ++c;
	if (c != k) { printf("0"); return 0; }
	st.insert(1e9 + 1);
	while (*it != 1e9 + 1) {
		set<int>::iterator t = it++;
		int lr = *t, rr = *it - 1;
		int lr1 = max(lr, l1), rr1 = min(rr, r1), lr2 = max(lr, l2), rr2 = min(rr, r2);
		t = it0++;
		int LL = *t + 1, rl = *it0;
		int ll1 = max(LL, l1), rl1 = min(rl, r1), ll2 = max(LL, l2), rl2 = min(rl, r2);
		if (rr1 >= lr1 && rl2 >= ll2)an += (long double)(rr1 - lr1 + 1) / s1 * (rl2 - ll2 + 1) / s2;
		if (rl1 >= ll1 && rr2 >= lr2)an += (long double)(rl1 - ll1 + 1) / s1 * (rr2 - lr2 + 1) / s2;
	}
	printf("%.10lf", (double)an);
}

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<climits>
#include<algorithm>
#include<map>
using namespace std;

#define N 10010
long long val[N];
int n, m;

int find(int v) {
	for (int i = 0; ; ++i) if (val[i] > v) return i;
}
int find2(int v) {
	for (int i = 0; ; ++i) if (val[i] >= v) return i;
}

void init()
{
	int i, j;
	val[0] = 0;
	for (i = j = 0; ; ++i) {
		val[++j] = val[i] * 10 + 4; val[++j] = val[i] * 10 + 7;
		if (val[j] > LONG_MAX) break;
	} m = j;
}

int main()
{
	long long vst, ved, ust, ued, cnt, cr, cl; int i, k, ul, ur;
	double ans;
	init();
	cin >> vst >> ved >> ust >> ued >> k;
	i = find(vst); n = find(ved); ul = find2(ust); ur = find2(ued);
	for (ans = 0; i <= n; ++i) {
		if (i-k >= ul && i-k <= ur) cl = min(val[i-k], ued)-max(val[i-k-1], ust-1); else cl = 0;
		ans += (double)(min(val[i], ved+1) - max(val[i-1], vst)) / (ved-vst+1) * (double)cl / (ued-ust+1);
//		printf("i:%d cl:%lld cnt:%lld\n", i, cl, cnt);
	} i = find2(vst); n = find2(ved); ul = find(ust); ur = find(ued);
	for (; i <= n; ++i) {
		if (i+k <= ur && i+k >= ul) cr = min(val[i+k], ued+1)-max(val[i+k-1], ust); else cr = 0;
		ans += (double)(min(val[i], ved) - max(val[i-1], vst-1)) / (ved-vst+1) * (double)cr / (ued-ust+1);
//		printf("i:%d cr:%lld cnt:%lld\n", i, cr, cnt);
	} printf("%.12f\n", ans);
}

#include "stdio.h"
#include <iostream>;
using namespace std;
unsigned int a[1023];
int min(int a, int b) {
	if (a > b) return b;
	else return a;
}
void swap(int *a, int *b) {
	int c;
	c = *a; *a = *b; *b = c;
}
int length_of_cross(int l1, int r1, int l2, int r2) { // l1 < l2
	if (r1 >= l2) {
		return min(r1, r2) - l2 + 1;
	}
	else return 0;
}
unsigned int create_new_prime(unsigned int x) {
	int p = x, q = 3, t = 3;
	while (p > 0) {
		if (p % 10 == 4) {
			x -= t; x += 2*q;
			break;
		}
		else {
			p /=10; q *= 10; t +=q;
		}
	}
	if (p > 0) return x;
	else return (q/3)*4 + (x/7)*4;
}
 int main() {
	int l1, r1, l2, r2, k;
	scanf("%d %d %d %d %d", &l1, &r1, &l2, &r2, &k);
	int p = 4, i;
	a[0] = 0;
	for (i = 1; i < 1023; i++) {
		a[i] = p;
		p = create_new_prime(p);
	}
	if (l2 < l1) {
			swap(&l1, &l2);
			swap(&r1, &r2);
	}
	int x, y, res = 0;
	for (i = 0; i < 1023 && i + k < 1023; i++) {
		int left = a[i], right = a[i + 1], left2 = a[i + k], right2 = a[i + k + 1];
		if (l1 < left) x = length_of_cross(l1, r1, left, right);
		else x = length_of_cross(left, right, l1, r1);
		if (l2 < left2) y = length_of_cross(l2, r2, left2, right2);
		else y = length_of_cross(left2, right2, l2, r2);
		res += x*y;
		if (l2 < left) x = length_of_cross(l2, r2, left, right);
		else x = length_of_cross(left, right, l2, r2);
		if (l1 < left2) y = length_of_cross(l1, r1, left2, right2);
		else y = length_of_cross(left2, right2, l1, r1);
		res += x*y;
	}
	unsigned long t = ((r1-l1 + 1)*(r2-l2 + 1));
	if (k == 1){
		for (i = 0; i < 1023; i++){
			if (a[i] >= l1 && a[i] <= r1 && a[i] >= l2 && a[i] <= r2) t++;
		}
	}
	double q = (double)res/t;
	cout.precision(12);
	cout << q;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int> v;
void rec(int n, int len, int p){
  if(len > 9){
    return;
  }
  len++;
  v.push_back(n+p*4);
  rec(n+p*4, len, p*10);
  v.push_back(n+p*7);
  rec(n+p*7, len, p*10);
}
signed main() {
  rec(0, 0, 1);
  v.push_back(0);
  sort(v.begin(), v.end());
  int pl, pr, vl ,vr, k;
  cin >> pl >> pr >> vl >> vr >> k;
  long double res = 0;
  for(int i = 0; i < v.size()-k; i++){
    int j = i+k-1;
    int f = v[i];
    int l = v[j];
    int ml = max(v[i-1], pl);
    int mr = min(v[i], pr);
    int mml = max(v[j], vl);
    int mmr = min(v[j+1], vr);
    if(ml <= mr && mml <= mmr){
        res += (mr-ml+1)*(mmr-mml+1);
    }
    ml = max(v[i-1], vl);
    mr = min(v[i], vr);
    mml = max(v[j], pl);
    mmr = min(v[j+1], pr);
    if(ml <= mr && mml <= mmr){
        res += (mr-ml+1)*(mmr-mml+1);
    }
  }
  cout << res/((pr-pl+1)*(vr-vl+1));
}

#include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<string>
#define mod 1000000007
#define inf 2000000000
using namespace std;
int l1,r1,l2,r2;
int k;
int mass[7027];
int tem[7027];
int coun;
void mergesort(int *a,int *b,int n)
{
    int i,i0,i1,iRight,iEnd,width,j;
    for(width=1;width<n;width*=2)
        for(i=0;i<n;i+=width*2)
        {
            i0=i;
            i1=iRight=min(i+width,n);
            iEnd=min(i+width*2,n);
            for(j=i;j<iEnd;j++)
                if(i0<iRight && (i1==iEnd || a[i0]<a[i1]))
                    b[j]=a[i0++];
                else
                    b[j]=a[i1++];
            for(j=i;j<iEnd;j++)
                a[j]=b[j];
        }
}
int d[10];
void dfs(int x,int res)
{
    if(x==9)
        return;
    mass[coun++]=res+d[x]*4;
    mass[coun++]=res+d[x]*7;
    dfs(x+1,res+d[x]*4);
    dfs(x+1,res+d[x]*7);
}
int main()
{
    cin>>l1>>r1>>l2>>r2>>k;
    long long ans=0;
    int i,j;
    d[0]=1;
    for(i=1;i<10;i++)
        d[i]=d[i-1]*10;
    dfs(0,0);
    mergesort(mass,tem,coun);
    for(i=coun;i>0;i--)
        mass[i]=mass[i-1];
    mass[coun+1]=inf;
    mass[0]=-inf;
    for(i=1;i+k<=coun;i++)
    {
        if(mass[i]>=l1 && mass[i-1]<r1)
            if(mass[i+k]>=l2 && mass[i+k-1]<r2)
                ans+=(long long)(min(r1,mass[i])-max(l1,mass[i-1]+1)+1)*(min(r2,mass[i+k]-1)-max(l2,mass[i+k-1])+1);
        if(mass[i]>=l2 && mass[i-1]<r2)
            if(mass[i+k]>=l1 && mass[i+k-1]<r1)
                ans+=(long long)(min(r2,mass[i])-max(l2,mass[i-1]+1)+1)*(min(r1,mass[i+k]-1)-max(l1,mass[i+k-1])+1);
    }
    long long del=(long long)(r1-l1+1)*(r2-l2+1);
    cout<<setprecision(20)<<(long double)ans/(long double)del<<endl;
    return 0;
}

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

#define LL long long
#define NL '\n'
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%I64d",&x)
#define sd(x) scanf("%lf",&x)
#define ss(x) scanf("%s",x)
#define mem(a,b) memset(a,b,sizeof(a))
#define FOR(i,j,k) for(i=j;i<=k;i++)
#define REV(i,j,k) for(i=j;i>=k;i--)
#define READ(f) freopen(f,"r",stdin)
#define WRITE(f) freopen(f,"w",stdout)
#define cnd tree[idx]
#define lnd tree[idx*2]
#define rnd tree[(idx*2)+1]
#define lndp (idx*2),(b),((b+e)/2)
#define rndp (idx*2+1),((b+e)/2+1),(e)
#define pi 2.0*acos(0.0)
#define MOD 1000000007
#define MAX 10000

int sz, lucky[MAX];

void go(LL n)
{
    if(n > MOD) return ;
    lucky[sz++] = n;
    go(n*10 + 4);
    go(n*10 + 7);
}

int main()
{
    //READ("input.txt");
    //WRITE("out.txt");
    std::ios_base::sync_with_stdio(0);
    int cases, caseno=0, n, i, j, k, pl, bl, br, pr, x, y;

    cin >> pl >> pr >> bl >> br >> k;

    sz = 0;
    go(4);
    go(7);

    sort(lucky,lucky+sz);

    double p_total = pr - pl + 1;
    double b_total = br - bl + 1;
    double sum = 0.0, low, high, cnt=0;

    FOR(i,k-1,sz-1)
    {
        bool flag = 0;
        if(pl <= lucky[i-k+1] && br >= lucky[i])
        {
            if(i >= k) low = max(0, min(pr,lucky[i-k+1])-max(pl,lucky[i-k]-1)+1);
            else low = max(0, min(pr,lucky[i-k+1])-pl+1);

            if(i < sz-1) high = max(0, min(br,lucky[i+1]-1)-max(bl,lucky[i])+1);
            else high = max(0, br-max(bl,lucky[i])+1);

            sum += ((low/p_total) * (high/b_total));
            flag = 1;
        }
        if(bl <= lucky[i-k+1] && pr >= lucky[i])
        {
            if(i >= k) low = max(0, min(br,lucky[i-k+1])-max(bl,lucky[i-k]-1)+1);
            else low = max(0, min(br,lucky[i-k+1])-bl+1);

            if(i < sz-1) high = max(0, min(pr,lucky[i+1]-1)-max(pl,lucky[i])+1);
            else high = max(0, pr-max(pl,lucky[i])+1);

            sum +=  ((low/b_total) * (high/p_total));
            flag = 1;
        }
        if(flag) cnt += 1.0;
    }

    //sum = sum / cnt;

    cout << fixed;
    cout << setprecision(12) << sum << NL;

    return 0;
}

#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <set>
#include <cstring>
#include <string>
#define LL long long int
using namespace std;
#define N 200005

int k,n1=0,n=0,x;
LL y,a[N],b[N],pl,pr,vl,vr,L,R;

LL AC = 0;

LL P_LEFT(int x){
	if (!x) return (min(b[x],pr)-pl+1);
	else return (min(b[x],pr)-max(pl,b[x-1]+1)+1);
}

LL V_LEFT(int x){
	if (!x) return (min(b[x],vr)-vl+1);
	else return (min(b[x],vr)-max(vl,b[x-1]+1)+1);
}

LL P_RIGHT(int x){
	if (x==n-1) return (pr-max(b[x],pl)+1);
	else return (min(pr,b[x+1]-1)-max(b[x],pl)+1);
}

LL V_RIGHT(int x){
	if (x==n-1) return (vr-max(b[x],vl)+1);
	else return (min(vr,b[x+1]-1)-max(b[x],vl)+1);
}

int main(){

	scanf("%I64d%I64d%I64d%I64d%d",&pl,&pr,&vl,&vr,&k);
	L = pr-pl+1;
	R = vr-vl+1;

	for (int i=1;i<=9;i++)
	for (int j=0;j<(1<<i);j++){

		x=j;
		y=0;
		for (int k=0;k<i;k++){
			if (x%2==0) y=y*10+4;
			else y=y*10+7;
			x/=2;
		}
		a[n1++]=y;
	}
	sort(a,a+n1);
	for (int i=0;i<n1;i++)
		if (!i || a[i]!=a[i-1])
			b[n++]=a[i];

	for (int i=0;i+k-1<n;i++){

		AC+=max(0LL,P_LEFT(i))*max(0LL,V_RIGHT(i+k-1));
		if (k!=1)
		AC+=max(0LL,V_LEFT(i))*max(0LL,P_RIGHT(i+k-1));
	}

	printf("%.15lf\n",AC*1.0/(L*1.0*R));

	//scanf("\n");
	return 0;
}

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

#define lo(x) (lower_bound(fs.begin(),fs.end(),x)-fs.begin())
#define up(x) (upper_bound(fs.begin(),fs.end(),x)-fs.begin())

int main(){

    cout<<setprecision(13);

    vector<int> fs;

    fs.push_back(4);
    fs.push_back(7);

    int a=0,b=2;

    for(int i=10; i<100000000; i=i*10){
        for(int j=a; j<b; j++){
            fs.push_back(4*i+fs[j]);
            fs.push_back(7*i+fs[j]);
        }
        a=b;
        b=fs.size();
    }

    int p1,p2,q1,q2,k;
    cin>>p1>>p2>>q1>>q2>>k;
    double s=0;

    if(up(q2)-lo(p1)>=k&&up(q1)-lo(p2)<=k){
        int i=max(lo(p1),up(q1)-k),lop=lo(p2),upq=up(q2);
        a=p1;
        while(i<=lop&&i+k<=upq){
            if(i+k==510){
                b=q2;
            }
            else{
                b=min(q2,fs[i+k]);
            }
            s=s+(min(fs[i],p2)-a+1)*(b-max(fs[i+k-1],q1)+1);
            cout<<"1 "<<s<<"  "<<i<<endl;
            a=fs[i]+1;
            i++;
        }
    }

    if(up(p2)-lo(q1)>=k&&up(p1)-lo(q2)<=k){
        int j=max(lo(q1),up(p1)-k),loq=lo(q2),upp=up(p2);
        a=q1;
        while(j<=loq&&j+k<=upp){
            if(j+k==510){
                b=p2;
            }
            else{
                b=min(p2,fs[j+k]);
            }
            s=s+(min(fs[j],q2)-a+1)*(b-max(fs[j+k-1],p1)+1);
            cout<<"2 "<<s<<endl;
            a=fs[j]+1;
            j++;
        }
    }

    cout<<s/((p2-p1+1)*(q2-q1+1));

    return 0;
}

// #pragma GCC optimize("Ofast")
#include"bits/stdc++.h"
using namespace std;

#define int long long
#define double long double
#define F first
#define S second
#define Z(c) (int)(c).size()
const int mod=1e9+7;
const int INF=2e9;
const int N=1e5+15;

 vector<string> split(const string& s, char c) {
     vector<string> v; stringstream ss(s); string x;
     while (getline(ss, x, c)) v.emplace_back(x); return move(v);
 }
 template<typename T, typename... Args>
 inline string arrStr(T arr, int n) {
     stringstream s; s << "[";
     for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
     s << arr[n - 1] << "]";
     return s.str();
 }

 #define EVARS(args...) {__evars_begin(__LINE__); __evars(split(#args, ',').begin(), args);}

 inline void __evars_begin(int line) { cerr << "#" << line << ": "; }
 template<typename T> inline void __evars_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
 template<typename T> inline void __evars_out_var(T* val) { cerr << arrStr(val, 10); }
 template<typename T> inline void __evars_out_var(T val) { cerr << val; }
 inline void __evars(vector<string>::iterator it) { cerr << endl; }

 template<typename T, typename... Args>
 inline void __evars(vector<string>::iterator it, T a, Args... args) {
     cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
     __evars_out_var(a);
     cerr << "; ";
     __evars(++it, args...);
 }

  int ovl(int x,int y,int l,int r){
     int mx=max(x,l),mn=min(y,r);
     return max(0LL,mn-mx+1);
  }

  void kudne()
 {
   vector<int> gen(1);

   for(int i=1;i<=9;++i){

       for(int j=0;j<(1<<i);++j){
           int t=0;
           for(int k=0;k<i;++k){
                if(j&(1<<k)) t=t*10+7;
                else t=t*10+4;
           }
           gen.push_back(t);
       }
   }

   int sz=gen.size();
   gen.push_back(1e9+1);

   int l1,r1,l2,r2,k; cin>>l1>>r1>>l2>>r2>>k;

   int ans=0;

   sort(gen.begin(),gen.end());

   for(int i=1;i+k<=sz;++i){
     ans+=ovl(l1,r1,gen[i-1]+1,gen[i])*ovl(l2,r2,gen[i+k-1],gen[i+k]-1);

     ans+=ovl(l2,r2,gen[i-1]+1,gen[i])*ovl(l1,r1,gen[i+k-1],gen[i+k]-1);
     // EVARS(i,ans,gen[i-1]+1,gen[i],gen[i+k-1],gen[i+k]-1);
     // EVARS(i,ans);
   }

   double d=(r1-l1+1)*(r2-l2+1),n=ans;
   n*=1.0; d*=1.0; n=n/d;
   cout<<setprecision(10)<<n;

 }

signed main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   #ifndef ONLINE_JUDGE
   freopen("input.txt","r", stdin);
   freopen("output.txt","w", stdout);
   freopen("error.txt","w", stderr);
   #endif

   int tc=1;
   // cin>>tc;

  for(int i=1;i<=tc;++i)
  { // cout<<"Case #"<<i<<": ";

   kudne();
   if(i<tc)
   cout<<"\n";
  }

  #ifndef ONLINE_JUDGE
  cerr<<(1000*clock())/CLOCKS_PER_SEC<<"ms";
  #endif

 return 0;
}

/*
***************************************************************************************************************

                            Author : Yash Sadhwani

**************************************************************************************************************
*/
#include<stdio.h>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<deque>
#include<map>
#include<set>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sd(x) scanf("%lf",&x)
#define sc(x) scanf("%c",&x)
#define ss(x) scanf("%s",x)
#define vl vector<ll>
#define vi vector<int>
#define vvl vector< vl >
#define vvi vector< vi >
#define pb push_back
#define mod 1000000007
#define mem(x,y) memset(x,y,sizeof(x))
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define max_int_value 2147483647
#define max_long_value 9223372036854775807
#define ub(X,v) upper_bound(X.begin(),X.end(),v)
#define lb(X,v) lower_bound(X.begin(),X.end(),v)

//qsort(ww,cc,sizeof(tp),compare);
/*int compare(const void *a,const void *b){
    ll y=((((tp*)a)->w)-(((tp*)b)->w));
    if(y>0)return 1;
    else if(y==0)return 0;
    else return -1;
}
bool way(ii x,ii y){
    return x.first<y.first or x.first==y.first and x.second<y.second;
}

ll modpow(ll base, ll exponent,ll modulus){
    if(base==0&&exponent==0)return 0;
    ll result = 1;
    while (exponent > 0){
        if (exponent % 2 == 1)
            result = (result * base) % modulus;
        exponent = exponent >> 1;
        base = (base * base) % modulus;
    }
    return result;
}

#define getchar_unlocked getchar
using namespace std;
inline int scan(){
    char c = getchar_unlocked();
    int x = 0;
    while(c<'0'||c>'9'){
        c=getchar_unlocked();
    }
    while(c>='0'&&c<='9'){
        x=(x<<1)+(x<<3)+c-'0';
        c=getchar_unlocked();
    }
    return x;
}

*/

#define MAXN 100010
#define SQRT 330
#define ls (node<<1)
#define rs ((node<<1)+1)
#define ii pair<int,int>
#define F first
#define S second

vi vp;

int p_l, p_r, v_l, v_r;

inline void pre(void){
    for(int i = 1; i <= 9; i++){
        int max_mask = (1 << i);
        for(int mask = 0; mask < max_mask; mask++){
            int curr = 0;
            int mul = 1;
            for(int j = 0; j < i; j++){
                if(mask & (1 << j)){
                    curr += (mul * 7);
                }else{
                    curr += (mul * 4);
                }
                mul *= 10;
            }
            vp.pb(curr);
        }
    }
    sort(vp.begin(), vp.end());
}

int K;

#define T long double

inline T power(T a, int p){
    T ret = 1;
    while(p > 0){
        if(p & 1){
            ret *= a;
        }
        a *= a;
        p /= 2;
    }
    return ret;
}

int inrange(int a, int b, int l, int r){
    int ret = min(b, r) - max(a, l) + 1;
    ret = max(ret, 0);
    return ret;
}

inline void ReadInput(void){
    si(p_l); si(p_r); si(v_l); si(v_r); si(K);
}

inline void solve(void){
    pre();
    //for(int i = 0; i < 2; i++) cout << vp[i] << " ";
    //cout << endl;
    double ans = 0;
    for(int i = 0; i < vp.size(); i++){
        if(i + K > vp.size()) break;
        int prev = (i ? vp[i - 1] : 0);
        int next = (i + K < (int) vp.size() ? vp[i + K] : 1e9 + 1);

        //min : v , max : p
        int cnt1, cnt2;
        cnt1 = inrange(v_l, v_r, prev + 1, vp[i]);
        cnt2 = inrange(p_l, p_r, vp[i + K - 1], next - 1);
        double g, f;
        g = cnt1 / (double) (v_r - v_l + 1);
        f = cnt2 / (double) (p_r - p_l + 1);
        ans += (g * f);
        //cout << (g * f) << " ";

        if(p_l == p_r and v_l == v_r and p_l == v_l) continue;
        //min : p , max : v
        cnt1 = inrange(p_l, p_r, prev + 1, vp[i]);
        cnt2 = inrange(v_l, v_r, vp[i + K - 1], next - 1);
        g = cnt1 / (double) (p_r - p_l + 1);
        f = cnt2 / (double) (v_r - v_l + 1);
        ans += (g * f);
        //cout << (g * f) << endl;

    }
    printf("%.10lf\n", ans );
}

inline void Refresh(void){

}

int main()
{
    //ios_base::sync_with_stdio(false);
    ReadInput();
    solve();
    return 0;
}

// U COME AT THE KING, BETTER NOT MISS !!!

#include <iostream>
#include <iomanip>
#include <algorithm>

using namespace std;
int is_lucky(int n);
int main() {
	int p1, p2, v1, v2,k;
	while (cin >> p1 >> p2 >> v1 >> v2 >> k) {
		double sum = 0;
		for (int start = p1;start <= p2;start++) {
			for (int end = v1;end <= v2;end++) {
				int flag = 0, i = min(start, end);
				while (flag != k && i <= max(start, end)) {
					if (is_lucky(i)) flag++;
					i++;
				}
				if (flag < k)continue;
				sum ++;
			}
		}
		cout <<fixed<<setprecision(12)<< sum/(p2-p1+1)/(v2-v1+1) << endl;
	}
	return 0;
}
int is_lucky(int n) {
	int i = n;
	while (i != 0) {
		if (i % 10 != 4 && i % 10 != 7)return 0;
		i /= 10;
	}
	return 1;
}

#include<cstdio>
#include<vector>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef long long ll;

const ll INF=1LL<<60;

void dfs(ll a,vector<ll> &L){
	if(a>10e9) return;

	L.push_back(10*a+4); dfs(10*a+4,L);
	L.push_back(10*a+7); dfs(10*a+7,L);
}

inline ll f(ll a,ll b,ll c,ll d){ return max(min(b,d)-max(a,c)+1,0LL); }

int main(){
	vector<ll> L;
	dfs(0,L);
	L.push_back(-INF);
	L.push_back(+INF);
	sort(L.begin(),L.end());

	ll pl,pr,vl,vr,k; scanf("%I64d%I64d%I64d%I64d%I64d",&pl,&pr,&vl,&vr,&k);

	ll cnt=0;
	for(int i=1;i<(int)L.size()-k;i++){
		cnt+=f(pl,pr,L[i-1]+1,L[i])*f(vl,vr,L[i+k-1],L[i+k]-1);
		cnt+=f(vl,vr,L[i-1]+1,L[i])*f(pl,pr,L[i+k-1],L[i+k]-1);
	}
	printf("%.15f\n",(double)(cnt)/((pr-pl+1)*(vr-vl+1)));

	return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define maxk 1023
int a[maxk];
//void cal()
//{
//	int a[maxn], num = 2, cnt = 0, i, k, t;
//	a[cnt++] = 4;
//	a[cnt++] = 7;
//	for(i = 2; i <= 9; i++)
//	{
//		t = cnt;
//		for(k = t - num; k <= t - 1; k++)
//		{
//			a[cnt++] = a[k] * 10 + 4;
//			a[cnt++] = a[k] * 10 + 7;
//		}
//		num <<= 1;
//	}
//}

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

    queue<int> q;
    q.push(4);
    q.push(7);
    int d = 1;
    int cnt = 0;
    while(!q.empty() && d < 10)
    {
    	int size = q.size();
    	while(size--)
    	{
    		int plucky = q.front();
    		a[cnt] = plucky;
    	    q.pop();
    	    q.push(plucky*10 + 4);
    	    q.push(plucky*10 + 7);
    	    cnt++;
    	}
    	d++;
    }

    //sort(luckies, luckies + cnt);

	int pl, pr, vl, vr, k;
	scanf("%d %d %d %d %d", &pl, &pr, &vl, &vr, &k);

	long long trueSpace = 0;
	for(int i = 0; i < maxk - k; i++)
	{
		int l1 = max(( i == 0? 1 : a[i - 1] + 1), pl);
		int r1 = min(a[i], pr);

		int l2 = max(a[i + k - 1] , vl);
		int r2 = min(( i + k == maxk? vr : a[i + k] - 1), vr);

		if(r1 >= l1 && r2 >= l2) trueSpace += (long long)(r1 - l1 + 1)*(r2 - l2 + 1);

	    l1 = max(( i == 0? 1 : a[i - 1] + 1), vl);
		r1 = min(a[i], vr);
		l2 = max(a[i + k - 1] , pl);
		r2 = min(( i + k == maxk? pr : a[i + k] - 1), pr);
		if(r1 >= l1 && r2 >= l2) trueSpace += (long long)(r1 - l1 + 1)*(r2 - l2 + 1);
	}

	double res = (double)trueSpace/((long long)(pr - pl + 1)*(vr - vl + 1));
	printf("%.10f", res);
	return 0;
}

#pragma comment(linker, "/STACK:100000000000000")
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string.h>
#include <cctype>
#include <cassert>
#include <ctime>
#define mp make_pair
#define pb push_back
#define lo long long int
//#define pi 3.14159265358979323
#define eps 1e-6
#define MN 300
using namespace std;
const lo INF= 2e15;
vector<lo> pr;
void dfs(lo id, lo r)
{
	if(id <= r)
	pr.push_back(id);
	if(id >= r) return;
	dfs(id * 10 + 4, r);
	dfs(id * 10 + 7, r);
}
lo cnt(lo a)
{
	return a * (a + 1) / 2;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	lo l, r, l2, r2, k, l3, r3, l4, r4;
	cin >> l >> r >> l2 >> r2 >> k;
	if(l > l2) swap(l, l2), swap(r, r2);
	lo num = 0;
	dfs(4, max(r, r2));
	dfs(7, max(r, r2));
	sort(pr.begin(), pr.end());
	if(r < l2)
	{
		num = (r - l + 1) * (r2 - l2 + 1);
	}
	else
	{
		num = (l2 - l + 1) * (max(r2, r) - l2 + 1);
		lo te = min(r, r2) - l2 ;
		num += ((max(r2, r) - l2 ) + (max(r2, r) - l2 - te)) * (te) / 2;
	}
	lo f = 0;
	for(lo i = 0; i < (lo) pr.size(); i++)
	{
		if(pr[i] < l) continue;
		lo j = i + k - 1;
		if(j >= (lo) pr.size() || pr[j] > max(r, r2)) continue;
		lo pi = (!i ? -INF : pr[i - 1] + 1);
		lo pj = (j == (lo) pr.size() - 1 ? INF : pr[j + 1] - 1);
		lo t1 = pr[i], t2 = pr[j];
		if(r < l2)
		{
			t1 = min(t1, r);
			t2 = max(t2, l2);
		}
		f += (t1 - max(l, pi) + 1) * (min(pj, max(r, r2)) - t2 + 1);
	}
	cout <<fixed << setprecision(10) << (double) f / (double) num;
}