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

int cmp(const void *a, const void *b)
{
     return *((int *)a) - *((int *)b);
}

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

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

int main()
{
     int a[2000];
     int p = 0, q = 1, x = 1, i, j;
     int pl, pr, vl, vr, k;
     long long c = 0, d;

     a[0] = 0;

     for (i = 0; i < 9; i++) {
	  for (j = p; j < q; j++) {
	       a[x++] = a[j] * 10 + 4;
	       a[x++] = a[j] * 10 + 7;
	  }

	  p = q; q = x;
     }

     qsort(a, x, sizeof(int), cmp);

     a[x] = 1000000001;

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

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

     for (i = 1; i <= x - k; i++) {
	  if (pl <= a[i] && vr >= a[i + k - 1]) {
	       int s1 = minimum(a[i], pr);
	       int s2 = maximum(a[i - 1] + 1, pl);
	       int t1 = maximum(a[i + k - 1], vl);
	       int t2 = minimum(a[i + k] - 1, vr);

	       if (s1 - s2 >= 0 && t2 - t1 >= 0) {
		    c += (long long)(s1 - s2 + 1) * (t2 - t1 + 1);
	       }
	  }
	  if (vl <= a[i] && pr >= a[i + k - 1]) {
	       int s1 = minimum(a[i], vr);
	       int s2 = maximum(a[i - 1] + 1, vl);
	       int t1 = maximum(a[i + k - 1], pl);
	       int t2 = minimum(a[i + k] - 1, pr);

	       if (s1 - s2 >= 0 && t2 - t1 >= 0) {
		    c += (long long)(s1 - s2 + 1) * (t2 - t1 + 1);
	       }
	  }
     }

     if (k == 1) {
	  for (i = 1; i < x; i++) {
	       if (pl <= a[i] && pr >= a[i] && vl <= a[i] && vr >= a[i]) c--;
	  }
     }

     printf("%.20lf\n", (double)c / d);

     return 0;
}

#include <stdio.h>
typedef long long ll;

ll lucky[2000];
int nl;

#define MIN(a,b) a<b?a:b
#define MAX(a,b) a>b?a:b

ll count2(ll minlow,ll maxlow,ll minhigh,ll maxhigh,ll pl,ll pr,ll vl,ll vr) {
  ll res=0;
  ll aa,ab,ba,bb,x,y;
  aa=MAX(pl,minlow);
  ab=MIN(pr,maxlow);
  ba=MAX(vl,minhigh);
  bb=MIN(vr,maxhigh);
  x=ab-aa+1;
  y=bb-ba+1;
  if(x>0 && y>0) res+=x*y;
  return res;
}

ll count3(ll minlow,ll maxlow,ll minhigh,ll maxhigh,ll pl,ll pr,ll vl,ll vr) {
  ll res=0;
  ll aa,ab,ba,bb,x,y;
  pl=MAX(pl,vl);
  pr=MIN(pr,vr);
  if(pl>pr) return 0;
  aa=MAX(minlow,pl);
  ab=MIN(maxlow,pr);
  ba=MAX(minhigh,pl);
  bb=MIN(maxhigh,pr);
  x=ab-aa+1;
  y=bb-ba+1;
  if(x>0 && y>0) res+=x+y;
  return res;
}

ll count(ll minlow,ll maxlow,ll minhigh,ll maxhigh,ll pl,ll pr,ll vl,ll vr) {
  ll res=0;
  res+=count2(minlow,maxlow,minhigh,maxhigh,pl,pr,vl,vr);
  res+=count2(minlow,maxlow,minhigh,maxhigh,vl,vr,pl,pr);
//  res-=count3(minlow,maxlow,minhigh,maxhigh,vl,vr,pl,pr);
  return res;
}

int main() {
  int i,j,k,K,maks,min;
  ll tall,tot,yes;
  int pl,pr,vl,vr;

  nl=0;
  lucky[nl++]=0;
  for(i=1;i<10;i++) {
    for(j=0;j<(1<<i);j++) {
      tall=0;
      for(k=0;k<i;k++) {
        if(j&(1<<(i-k-1))) tall=tall*10+7;
        else tall=tall*10+4;
      }
      lucky[nl++]=tall;
    }
  }
  lucky[nl++]=1000000000000000LL;

again:
  if(scanf("%d %d %d %d %d",&pl,&pr,&vl,&vr,&K)!=5) return 0;
  tot=(pr-pl+1LL)*(vr-vl+1LL);
  yes=0;
  maks=pr>vr?pr:vr;
  min=pl<vl?pl:vl;

  for(i=0;;i++) {
    if(i+K+1>=nl) break;
    if(lucky[i+K]>maks) break;
/*    printf("try %I64d %I64d %I64d %I64d\n",lucky[i]+1,lucky[i+1],lucky[i+K],lucky[i+K+1]-1);*/
    yes+=count(lucky[i]+1,lucky[i+1],lucky[i+K],lucky[i+K+1]-1,pl,pr,vl,vr);
  }
  if(K==1) {
    for(i=1;i<nl-1;i++) {
      if(lucky[i]>=vl && lucky[i]>=pl && lucky[i]<=vr && lucky[i]<=pr) yes--;
    }
  }
  printf("%.12f\n",(double)((long double)yes/tot));
  goto again;
  return 0;
}

#include <stdio.h>
#define abs(a) (((a) < 0) ? (-(a)) : (a))
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

long long a[2500];
int m;

void
gen(int n, int i, long long num)
{
    if(i == n){
        a[m++] = num;
    } else {
        gen(n, i + 1, num * 10 + 4);
        gen(n, i + 1, num * 10 + 7);
    }
}

void
swap(long long *a, long long *b)
{
    long long tmp = *a;
    *a = *b;
    *b = tmp;
}

long long p_l, p_r, v_l, v_r, all, good, trash;
int k;

int
main(void)
{
    a[m++] = 0;
    int i, j;
    for(i = 1; i <= 10; ++i)
        gen(i, 0, 0);
    scanf("%I64d%I64d%I64d%I64d%d", &p_l, &p_r, &v_l, &v_r, &k);
    all = (p_r - p_l + 1) * (v_r - v_l + 1);
    for(j = 0; j < 2; ++j){
        for(i = 1; i + k < m; ++i){
            long long l1 = max(a[i - 1], p_l),
                      r1 = min(a[i], p_r);
            if(l1 == a[i - 1]) ++l1;
            long long l2 = max(a[i + k - 1], v_l),
                      r2 = min(a[i + k], v_r);
            if(r2 == a[i + k]) --r2;
            if(l1 <= r1 && l2 <= r2){
                good += (r1 - l1 + 1) * (r2 - l2 + 1);
            }
            if(k == 1 && r1 == a[i] && l2 == a[i]){
                ++trash;
            }
        }
        swap(&p_l, &v_l);
        swap(&p_r, &v_r);
    }
    good -= trash / 2;
    double ans = (double)good / all;
    printf("%.15lf", ans);
    return 0;
}

#include <stdio.h>
int checkIsLucky(int num){
    while(num>0){
        if(num%10!=4&&num%10!=7)return 0;
        num/=10;
    }
    return 1;
}
int nextNum(int num){
    int nextN;
    int count=1;
    int maxNextD=0;
    nextN=num;
    if(num>=777777777) return 1000000001;
    while(num>0){
        if(num%10==4){
            nextN+=count*3;
            nextN=nextN/(count)*count+maxNextD;
            break;
        }else{
            maxNextD*=10;
            maxNextD+=4;
            num/=10;
            count*=10;
        }
    }
    if(num>0) return nextN;
    else{
        maxNextD*=10;
        maxNextD+=4;
        return maxNextD;
    }
}

int max(int a,int b){
    if(a>b) return a;
    else return b;
}
int min(int a,int b){
    if(a>b) return b;
    else return a;
}
int kthNum(int begin,int k){
    int count=1;
    int rt=0,tmp=begin;
    while (tmp>0) {
        tmp/=10;
        rt*=10;
        rt+=4;
    }
    while(rt<begin)rt=nextNum(rt);
    for(;count<k;count++){
        rt=nextNum(rt);
    }
    return rt;
}
int ma,mi;
double lenthRt(unsigned a,unsigned b,unsigned lk1,unsigned lk2){
    mi=max(a,lk1);
    ma=min(b,lk2);
    double kq;
    if(ma<mi) return 0;
    else {
        if(lk2==ma){
            kq=ma-mi;
            return kq;
        }

        kq= ma-mi+1;
        return kq;
    }
}
int main(){
    int pl,pr,vl,vr,k;
    int minN,maxN,lk1,lk2,i,after;
    double sum=0;

    double kq,mau;
    //pl=5;pr=6;
    //vl=8;vr=10;k=1;
    //printf("%d",nextNum(47));
    /*for(i=4;i<1000000000;i=nextNum(i)){
            printf("%d\n",i);

    }*/
    scanf("%d %d %d %d %d",&pl,&pr,&vl,&vr,&k);
    minN=min(pl,vl);
    maxN=max(pr,vr);

    //for p
    after=kthNum(pl,1);
    if(k==1){
        for(i=after;i<=pr;i=nextNum(i)) {
            //printf("%d\n",i);
            if(i>=vl&&i<=vr) sum-=1;
            getchar();
        }
    }
    lk1= kthNum(pl,k);
    lk2= nextNum(lk1);
    i=pl;
    for(;i<=pr;){//xet tat ca cac chu so trong [pl+1,pr]
        sum+=lenthRt(vl,vr,lk1,lk2)*min(after-i+1,pr-i+1);
        //printf("%d to %d-> %d %d + them %lf*%d->%lf\n",i,after,lk1,lk2,lenthRt(vl,vr,lk1,lk2),min(after-i+1,pr-i+1),sum);

        i=after+1;
        after=nextNum(after);
        lk1=lk2;
        if(lk1>vr) break;
        lk2=nextNum(lk2);
    }
    //if k==1

    //for p
    after=kthNum(vl,1);
    lk1= kthNum(vl,k);
    lk2= nextNum(lk1);
    i=vl;
    for(;i<=vr;){//xet tat ca cac chu so trong [pl+1,pr]
        //if(vl==vr&&pl==pr&&pl==vr) break;
        sum+=lenthRt(pl,pr,lk1,lk2)*min(after-i+1,vr-i+1);
        //printf("%d to %d-> %d %d + them %lf*%d ->%lf\n",i,after,lk1,lk2,lenthRt(pl,pr,lk1,lk2),min(after-i+1,pr-i+1),sum);

        i=after+1;
        after=nextNum(after);
        lk1=lk2;
        if(lk1>pr) break;
        lk2=nextNum(lk2);
    }
    mau=(pr-pl+1);
    mau*=     (vr-vl+1);
    //printf("%lf %lf");
    //printf("%lf %lf\n",sum,mau);
    kq=sum/mau;

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

/* practice with Dukkha */
#include <stdio.h>

#define A	1000000000

int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }

long long lucky(int i) {
	return i == 1 ? 0 : lucky(i / 2) * 10 + (i % 2 == 0 ? 4 : 7);
}

int intersect(int al, int ar, int bl, int br) {
	int l = max(al, bl);
	int r = min(ar, br);

	return max(r - l + 1, 0);
}

int main() {
	static int qq[1024];
	int ul, ur, vl, vr, k, cnt, i, j;
	long long a, cnt_;

	scanf("%d%d%d%d%d", &ul, &ur, &vl, &vr, &k);
	cnt = 0;
	qq[cnt++] = 0;
	for (i = 2; (a = lucky(i)) <= A; i++)
		qq[cnt++] = a;
	qq[cnt++] = A + 1;
	cnt_ = 0;
	for (i = 1; (j = i + k - 1) < cnt - 1; i++) {
		int pl = qq[i - 1] + 1, pr = qq[i];
		int ql = qq[j], qr = qq[j + 1] - 1;

		cnt_ += (long long) intersect(ul, ur, pl, pr) * intersect(vl, vr, ql, qr);
		cnt_ += (long long) intersect(ul, ur, ql, qr) * intersect(vl, vr, pl, pr);
		if (i == j && ul <= qq[i] && qq[i] <= ur && vl <= qq[i] && qq[i] <= vr)
			cnt_--;
	}
	printf("%.9f\n", (double) cnt_ / (ur - ul + 1) / (vr - vl + 1));
	return 0;
}

#include <stdio.h>
typedef long long ll;

ll lucky[2000];
int nl;

#define MIN(a,b) a<b?a:b
#define MAX(a,b) a>b?a:b

ll count2(ll minlow,ll maxlow,ll minhigh,ll maxhigh,ll pl,ll pr,ll vl,ll vr) {
  ll res=0;
  ll aa,ab,ba,bb,x,y;
  aa=MAX(pl,minlow);
  ab=MIN(pr,maxlow);
  ba=MAX(vl,minhigh);
  bb=MIN(vr,maxhigh);
  x=ab-aa+1;
  y=bb-ba+1;
  if(x>0 && y>0) res+=x*y;
  return res;
}

ll count3(ll minlow,ll maxlow,ll minhigh,ll maxhigh,ll pl,ll pr,ll vl,ll vr) {
  ll res=0;
  ll aa,ab,ba,bb,x,y;
  pl=MAX(pl,vl);
  pr=MIN(pr,vr);
  if(pl>pr) return 0;
  aa=MAX(minlow,pl);
  ab=MIN(maxlow,pr);
  ba=MAX(minhigh,pl);
  bb=MIN(maxhigh,pr);
  x=ab-aa+1;
  y=bb-ba+1;
  if(x>0 && y>0) res+=x+y;
  return res;
}

ll count(ll minlow,ll maxlow,ll minhigh,ll maxhigh,ll pl,ll pr,ll vl,ll vr) {
  ll res=0;
  res+=count2(minlow,maxlow,minhigh,maxhigh,pl,pr,vl,vr);
  res+=count2(minlow,maxlow,minhigh,maxhigh,vl,vr,pl,pr);
//  res-=count3(minlow,maxlow,minhigh,maxhigh,vl,vr,pl,pr);
  return res;
}

int main() {
  int i,j,k,K,maks,min;
  ll tall,tot,yes;
  int pl,pr,vl,vr;

  nl=0;
  lucky[nl++]=0;
  for(i=1;i<10;i++) {
    for(j=0;j<(1<<i);j++) {
      tall=0;
      for(k=0;k<i;k++) {
        if(j&(1<<(i-k-1))) tall=tall*10+7;
        else tall=tall*10+4;
      }
      lucky[nl++]=tall;
    }
  }
  lucky[nl++]=1000000000000000LL;

again:
  if(scanf("%d %d %d %d %d",&pl,&pr,&vl,&vr,&K)!=5) return 0;
  tot=(pr-pl+1LL)*(vr-vl+1LL);
  yes=0;
  maks=pr>vr?pr:vr;
  min=pl<vl?pl:vl;

  for(i=0;;i++) {
    if(i+K+2>=nl) break;
    if(lucky[i+K]>maks) break;
/*    printf("try %I64d %I64d %I64d %I64d\n",lucky[i]+1,lucky[i+1],lucky[i+K],lucky[i+K+1]-1);*/
    yes+=count(lucky[i]+1,lucky[i+1],lucky[i+K],lucky[i+K+1]-1,pl,pr,vl,vr);
  }
  if(K==1) {
    for(i=1;i<nl-1;i++) {
      if(lucky[i]>=vl && lucky[i]>=pl && lucky[i]<=vr && lucky[i]<=pr) yes--;
    }
  }
  printf("%.12f\n",(double)((long double)yes/tot));
  goto again;
  return 0;
}

#include <stdio.h>
typedef long long ll;

ll lucky[2000];
int nl;

#define MIN(a,b) a<b?a:b
#define MAX(a,b) a>b?a:b

ll count2(ll minlow,ll maxlow,ll minhigh,ll maxhigh,ll pl,ll pr,ll vl,ll vr) {
  ll res=0;
  ll aa,ab,ba,bb,x,y;
  aa=MAX(pl,minlow);
  ab=MIN(pr,maxlow);
  ba=MAX(vl,minhigh);
  bb=MIN(vr,maxhigh);
  x=ab-aa+1;
  y=bb-ba+1;
  if(x>0 && y>0) res+=x*y;
  return res;
}

ll count3(ll minlow,ll maxlow,ll minhigh,ll maxhigh,ll pl,ll pr,ll vl,ll vr) {
  ll res=0;
  ll aa,ab,ba,bb,x,y;
  pl=MAX(pl,vl);
  pr=MIN(pr,vr);
  if(pl>pr) return 0;
  aa=MAX(minlow,pl);
  ab=MIN(maxlow,pr);
  ba=MAX(minhigh,pl);
  bb=MIN(maxhigh,pr);
  x=ab-aa+1;
  y=bb-ba+1;
  if(x>0 && y>0) res+=x+y;
  return res;
}

ll count(ll minlow,ll maxlow,ll minhigh,ll maxhigh,ll pl,ll pr,ll vl,ll vr) {
  ll res=0;
  res+=count2(minlow,maxlow,minhigh,maxhigh,pl,pr,vl,vr);
  res+=count2(minlow,maxlow,minhigh,maxhigh,vl,vr,pl,pr);
//  res-=count3(minlow,maxlow,minhigh,maxhigh,vl,vr,pl,pr);
  return res;
}

int main() {
  int i,j,k,K,maks,min;
  ll tall,tot,yes;
  int pl,pr,vl,vr;

  nl=0;
  lucky[nl++]=0;
  for(i=1;i<10;i++) {
    for(j=0;j<(1<<i);j++) {
      tall=0;
      for(k=0;k<i;k++) {
        if(j&(1<<(i-k-1))) tall=tall*10+7;
        else tall=tall*10+4;
      }
      lucky[nl++]=tall;
    }
  }
  lucky[nl++]=1000000000000000LL;

again:
  if(scanf("%d %d %d %d %d",&pl,&pr,&vl,&vr,&K)!=5) return 0;
  tot=(pr-pl+1LL)*(vr-vl+1LL);
  yes=0;
  maks=pr>vr?pr:vr;
  min=pl<vl?pl:vl;

  for(i=0;;i++) {
    if(i+K+2>=nl) break;
    if(lucky[i+K]>maks) break;
/*    printf("try %I64d %I64d %I64d %I64d\n",lucky[i]+1,lucky[i+1],lucky[i+K],lucky[i+K+1]-1);*/
    yes+=count(lucky[i]+1,lucky[i+1],lucky[i+K],lucky[i+K+1]-1,pl,pr,vl,vr);
  }
  if(K==1) {
    for(i=1;i<nl-1;i++) {
      if(lucky[i]>=vl && lucky[i]>=pl && lucky[i]<=vr && lucky[i]<=pr) yes--;
    }
  }
  printf("%.12f\n",(double)yes/tot);
  goto again;
  return 0;
}

#include <stdio.h>
typedef long long ll;

ll lucky[2000];
int nl;

#define MIN(a,b) a<b?a:b
#define MAX(a,b) a>b?a:b

ll count2(ll minlow,ll maxlow,ll minhigh,ll maxhigh,ll pl,ll pr,ll vl,ll vr) {
  ll res=0;
  ll aa,ab,ba,bb,x,y;
  aa=MAX(pl,minlow);
  ab=MIN(pr,maxlow);
  ba=MAX(vl,minhigh);
  bb=MIN(vr,maxhigh);
  x=ab-aa+1;
  y=bb-ba+1;
  if(x>0 && y>0) res+=x*y;
  return res;
}

ll count(ll minlow,ll maxlow,ll minhigh,ll maxhigh,ll pl,ll pr,ll vl,ll vr) {
  ll res=0;
  res+=count2(minlow,maxlow,minhigh,maxhigh,pl,pr,vl,vr);
  res+=count2(minlow,maxlow,minhigh,maxhigh,vl,vr,pl,pr);
  return res;
}

int main() {
  int i,j,k,K,maks,min;
  ll tall,tot,yes=0;
  int pl,pr,vl,vr;
  scanf("%d %d %d %d %d",&pl,&pr,&vl,&vr,&K);
  tot=(pr-pl+1LL)*(vr-vl+1LL);
  maks=pr>vr?pr:vr;
  min=pl<vl?pl:vl;

  nl=0;
  lucky[nl++]=0;
  for(i=1;i<10;i++) {
    for(j=0;j<(1<<i);j++) {
      tall=0;
      for(k=0;k<i;k++) {
        if(j&(1<<k)) tall=tall*10+7;
        else tall=tall*10+4;
      }
      lucky[nl++]=tall;
    }
  }
  lucky[nl++]=1000000000000000LL;
  for(i=0;;i++) {
    if(i+K+2>=nl) break;
    if(lucky[i+K]>maks) break;
/*    printf("try %I64d %I64d %I64d %I64d\n",lucky[i],lucky[i+1],lucky[i+K],lucky[i+K+1]);*/
    yes+=count(lucky[i]+1,lucky[i+1],lucky[i+K],lucky[i+K+1]-1,pl,pr,vl,vr);
  }
  if(K==1) {
    for(i=1;i<nl-1;i++) {
      tall=lucky[i];
      if(tall>=pl && tall<=pr && tall>=vl && tall<=vr) yes--;
    }
  }
  printf("%.12f\n",(double)yes/tot);
  return 0;
}

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

int cmp(const void *a, const void *b)
{
     return *((int *)a) - *((int *)b);
}

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

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

int main()
{
     int a[1000];
     int p = 0, q = 1, x = 1, i, j;
     int pl, pr, vl, vr, k;
     long long c = 0, d;

     a[0] = 0;

     for (i = 0; i < 8; i++) {
	  for (j = p; j < q; j++) {
	       a[x++] = a[j] * 10 + 4;
	       a[x++] = a[j] * 10 + 7;
	  }

	  p = q; q = x;
     }

     qsort(a, x, sizeof(int), cmp);

     a[x] = 1000000001;

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

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

     for (i = 1; i <= x - k; i++) {
	  if (pl <= a[i] && vr >= a[i + k - 1]) {
	       int s1 = minimum(a[i], pr);
	       int s2 = maximum(a[i - 1], pl);
	       int t1 = maximum(a[i + k - 1], vl);
	       int t2 = minimum(a[i + k], vr);

	       if (s1 - s2 >= 0 && t2 - t1 >= 0) {
		    c += (long long)(s1 - s2 + 1) * (t2 - t1 + 1);

		    if (pr >= a[i] && vl <= a[i + k] && vr >= a[i + k]) c--;
		    if (pl <= a[i - 1] && pr >= a[i - 1] && vl <= a[i + k - 1]) c--;
	       }
	  }
	  if (vl <= a[i] && pr >= a[i + k - 1]) {
	       int s1 = minimum(a[i], vr);
	       int s2 = maximum(a[i - 1], vl);
	       int t1 = maximum(a[i + k - 1], pl);
	       int t2 = minimum(a[i + k], pr);

	       if (s1 - s2 >= 0 && t2 - t1 >= 0) {
		    c += (long long)(s1 - s2 + 1) * (t2 - t1 + 1);

		    if (vr >= a[i] && pl <= a[i + k] && pr >= a[i + k]) c--;
		    if (vl <= a[i - 1] && vr >= a[i - 1] && pl <= a[i + k - 1]) c--;
	       }
	  }
     }

     for (i = 0; i <= x - k; i++) {
	  if (pl <= a[i] && pr >= a[i] && vl <= a[i + k] && vr >= a[i + k]) c++;
	  if (vl <= a[i] && vr >= a[i] && pl <= a[i + k] && pr >= a[i + k]) c++;
     }

     printf("%.20lf\n", (double)c / d);

     return 0;
}

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

int cmp(const void *a, const void *b)
{
     return *((int *)a) - *((int *)b);
}

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

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

int main()
{
     int a[1000];
     int p = 0, q = 1, x = 1, i, j;
     int pl, pr, vl, vr, k;
     long long c = 0, d;

     a[0] = 0;

     for (i = 0; i < 8; i++) {
	  for (j = p; j < q; j++) {
	       a[x++] = a[j] * 10 + 4;
	       a[x++] = a[j] * 10 + 7;
	  }

	  p = q; q = x;
     }

     qsort(a, x, sizeof(int), cmp);

     a[x] = 1000000000;

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

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

     for (i = 1; i <= x - k; i++) {
	  if (pl <= a[i] && vr >= a[i + k - 1]) {
	       int s1 = minimum(a[i], pr);
	       int s2 = maximum(a[i - 1], pl);
	       int t1 = maximum(a[i + k - 1], vl);
	       int t2 = minimum(a[i + k], vr);

	       if (s1 - s2 >= 0 && t2 - t1 >= 0) {
		    c += (long long)(s1 - s2 + 1) * (t2 - t1 + 1);
	       }
	  }
	  if (vl <= a[i] && pr >= a[i + k - 1]) {
	       int s1 = minimum(a[i], vr);
	       int s2 = maximum(a[i - 1], vl);
	       int t1 = maximum(a[i + k - 1], pl);
	       int t2 = minimum(a[i + k], pr);

	       if (s1 - s2 >= 0 && t2 - t1 >= 0) {
		    c += (long long)(s1 - s2 + 1) * (t2 - t1 + 1);
	       }
	  }
     }

     printf("%.20lf\n", (double)c / d);

     return 0;
}

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

int cmp(const void *a, const void *b)
{
     return *((int *)a) - *((int *)b);
}

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

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

int main()
{
     int a[1000];
     int p = 0, q = 1, x = 1, i, j;
     int pl, pr, vl, vr, k;
     long long c = 0, d;

     a[0] = 0;

     for (i = 0; i < 8; i++) {
	  for (j = p; j < q; j++) {
	       a[x++] = a[j] * 10 + 4;
	       a[x++] = a[j] * 10 + 7;
	  }

	  p = q; q = x;
     }

     qsort(a, x, sizeof(int), cmp);

     a[x] = 1000000000;

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

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

     for (i = 1; i <= x - k; i++) {
	  if (pl <= a[i] && vr >= a[i + k - 1]) {
	       int s1 = minimum(a[i], pr);
	       int s2 = maximum(a[i - 1], pl);
	       int t1 = maximum(a[i + k - 1], vl);
	       int t2 = minimum(a[i + k], vr);
	       long long m = (long long)(s1 - s2 + 1) * (t2 - t1 + 1);

	       if (m > 0) c += m;
	  }
	  if (vl <= a[i] && pr >= a[i + k - 1]) {
	       int s1 = minimum(a[i], vr);
	       int s2 = maximum(a[i - 1], vl);
	       int t1 = maximum(a[i + k - 1], pl);
	       int t2 = minimum(a[i + k], pr);
	       long long m = (long long)(s1 - s2 + 1) * (t2 - t1 + 1);

	       if (m > 0) c += m;
	  }
     }

     printf("%.20lf\n", (double)c / d);

     return 0;
}

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

int cmp(const void *a, const void *b)
{
     return *((int *)a) - *((int *)b);
}

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

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

int main()
{
     int a[1000];
     int p = 0, q = 2, x = 2, i, j;
     int pl, pr, vl, vr, k;
     long long c = 0, d;

     a[0] = 4; a[1] = 7;

     for (i = 0; i < 7; i++) {
	  for (j = p; j < q; j++) {
	       a[x++] = a[j] * 10 + 4;
	       a[x++] = a[j] * 10 + 7;
	  }

	  p = q; q = x;
     }

     qsort(a, x, sizeof(int), cmp);

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

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

     for (i = 0; i <= x - k; i++) {
	  if (pl <= a[i] && vr >= a[i + k - 1]) {
	       int s = minimum(a[i], pr);
	       int t = maximum(a[i + k - 1], vl);

	       c += (long long)(s - pl + 1) * (vr - t + 1);

	       pl = s + 1; vr = t - 1;
	  }
	  if (vl <= a[i] && pr >= a[i + k - 1]) {
	       int s = minimum(a[i], vr);
	       int t = maximum(a[i + k - 1], pl);

	       c += (long long)(s - vl + 1) * (pr - t + 1);

	       vl = s + 1; pr = t - 1;
	  }
     }

     printf("%.20lf\n", (double)c / d);

     return 0;
}

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

int cmp(const void *a, const void *b)
{
     return *((int *)a) - *((int *)b);
}

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

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

int main()
{
     int a[1000];
     int p = 0, q = 1, x = 1, i, j;
     int pl, pr, vl, vr, k;
     long long c = 0, d;

     a[0] = 0;

     for (i = 0; i < 8; i++) {
	  for (j = p; j < q; j++) {
	       a[x++] = a[j] * 10 + 4;
	       a[x++] = a[j] * 10 + 7;
	  }

	  p = q; q = x;
     }

     qsort(a, x, sizeof(int), cmp);

     a[x] = 1000000000;

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

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

     for (i = 1; i <= x - k; i++) {
	  if (pl <= a[i] && vr >= a[i + k - 1]) {
	       int s1 = minimum(a[i], pr);
	       int s2 = maximum(a[i - 1], pl);
	       int t1 = maximum(a[i + k - 1], vl);
	       int t2 = minimum(a[i + k], vr);

	       c += (long long)(s1 - s2 + 1) * (t2 - t1 + 1);
	  }
	  if (vl <= a[i] && pr >= a[i + k - 1]) {
	       int s1 = minimum(a[i], vr);
	       int s2 = maximum(a[i - 1], vl);
	       int t1 = maximum(a[i + k - 1], pl);
	       int t2 = minimum(a[i + k], pr);

	       c += (long long)(s1 - s2 + 1) * (t2 - t1 + 1);
	  }
     }

     printf("%.20lf\n", (double)c / d);

     return 0;
}

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

int cmp(const void *a, const void *b)
{
     return *((int *)a) - *((int *)b);
}

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

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

int main()
{
     int a[1000];
     int p = 0, q = 1, x = 1, i, j;
     int pl, pr, vl, vr, k;
     long long c = 0, d;

     a[0] = 0;

     for (i = 0; i < 8; i++) {
	  for (j = p; j < q; j++) {
	       a[x++] = a[j] * 10 + 4;
	       a[x++] = a[j] * 10 + 7;
	  }

	  p = q; q = x;
     }

     qsort(a, x, sizeof(int), cmp);

     a[x] = 1000000001;

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

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

     for (i = 1; i <= x - k; i++) {
	  if (pl <= a[i] && vr >= a[i + k - 1]) {
	       int s1 = minimum(a[i], pr);
	       int s2 = maximum(a[i - 1] + 1, pl);
	       int t1 = maximum(a[i + k - 1], vl);
	       int t2 = minimum(a[i + k] - 1, vr);

	       if (s1 - s2 >= 0 && t2 - t1 >= 0) {
		    c += (long long)(s1 - s2 + 1) * (t2 - t1 + 1);
	       }
	  }
	  if (vl <= a[i] && pr >= a[i + k - 1]) {
	       int s1 = minimum(a[i], vr);
	       int s2 = maximum(a[i - 1] + 1, vl);
	       int t1 = maximum(a[i + k - 1], pl);
	       int t2 = minimum(a[i + k] - 1, pr);

	       if (s1 - s2 >= 0 && t2 - t1 >= 0) {
		    c += (long long)(s1 - s2 + 1) * (t2 - t1 + 1);
	       }
	  }
     }

     if (k == 1) {
	  for (i = 1; i < x; i++) {
	       if (pl <= a[i] && pr >= a[i] && vl <= a[i] && vr >= a[i]) c--;
	  }
     }

     printf("%.20lf\n", (double)c / d);

     return 0;
}

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

int cmp(const void *a, const void *b)
{
     return *((int *)a) - *((int *)b);
}

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

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

int main()
{
     int a[1000];
     int p = 0, q = 1, x = 1, i, j;
     int pl, pr, vl, vr, k;
     long long c = 0, d;

     a[0] = 0;

     for (i = 0; i < 8; i++) {
	  for (j = p; j < q; j++) {
	       a[x++] = a[j] * 10 + 4;
	       a[x++] = a[j] * 10 + 7;
	  }

	  p = q; q = x;
     }

     qsort(a, x, sizeof(int), cmp);

     a[x] = 1000000000;

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

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

     for (i = 1; i <= x - k; i++) {
	  if (pl <= a[i] && vr >= a[i + k - 1]) {
	       int s1 = minimum(a[i], pr);
	       int s2 = maximum(a[i - 1], pl);
	       int t1 = maximum(a[i + k - 1], vl);
	       int t2 = minimum(a[i + k], vr);

	       if (s1 - s2 >= 0 && t2 - t1 >= 0) {
		    c += (long long)(s1 - s2 + 1) * (t2 - t1 + 1);

		    if (pr >= a[i] && vl <= a[i + k - 1]) c--;
	       }
	  }
	  if (vl <= a[i] && pr >= a[i + k - 1]) {
	       int s1 = minimum(a[i], vr);
	       int s2 = maximum(a[i - 1], vl);
	       int t1 = maximum(a[i + k - 1], pl);
	       int t2 = minimum(a[i + k], pr);

	       if (s1 - s2 >= 0 && t2 - t1 >= 0) {
		    c += (long long)(s1 - s2 + 1) * (t2 - t1 + 1);

		    if (vr >= a[i] && pl <= a[i + k - 1]) c--;
	       }
	  }
     }

     for (i = 1; i <= x - k; i++) {
	  if (pl <= a[i] && pr >= a[i] && vl <= a[i + k - 1] && vr >= a[i + k - 1]) c++;
	  if (vl <= a[i] && vr >= a[i] && pl <= a[i + k - 1] && pr >= a[i + k - 1]) c++;
     }

     printf("%.20lf\n", (double)c / d);

     return 0;
}

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

int cmp(const void *a, const void *b)
{
     return *((int *)a) - *((int *)b);
}

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

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

int main()
{
     int a[1000];
     int p = 0, q = 1, x = 1, i, j;
     int pl, pr, vl, vr, k;
     long long c = 0, d;

     a[0] = 0;

     for (i = 0; i < 8; i++) {
	  for (j = p; j < q; j++) {
	       a[x++] = a[j] * 10 + 4;
	       a[x++] = a[j] * 10 + 7;
	  }

	  p = q; q = x;
     }

     qsort(a, x, sizeof(int), cmp);

     a[x] = 1000000001;

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

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

     for (i = 1; i <= x - k; i++) {
	  if (pl <= a[i] && vr >= a[i + k - 1]) {
	       int s1 = minimum(a[i], pr);
	       int s2 = maximum(a[i - 1] + 1, pl);
	       int t1 = maximum(a[i + k - 1], vl);
	       int t2 = minimum(a[i + k] - 1, vr);

	       if (s1 - s2 >= 0 && t2 - t1 >= 0) {
		    c += (long long)(s1 - s2 + 1) * (t2 - t1 + 1);
	       }
	  }
	  if (vl <= a[i] && pr >= a[i + k - 1]) {
	       int s1 = minimum(a[i], vr);
	       int s2 = maximum(a[i - 1] + 1, vl);
	       int t1 = maximum(a[i + k - 1], pl);
	       int t2 = minimum(a[i + k] - 1, pr);

	       if (s1 - s2 >= 0 && t2 - t1 >= 0) {
		    c += (long long)(s1 - s2 + 1) * (t2 - t1 + 1);
	       }
	  }
     }

     printf("%.20lf\n", (double)c / d);

     return 0;
}

//      Lucky Probability.c
//
//      Copyright 2011 Administrator <cpy@ubuntu>
//
//      This program is free software; you can redistribute it and/or modify
//      it under the terms of the GNU General Public License as published by
//      the Free Software Foundation; either version 2 of the License, or
//      (at your option) any later version.
//
//      This program is distributed in the hope that it will be useful,
//      but WITHOUT ANY WARRANTY; without even the implied warranty of
//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//      GNU General Public License for more details.
//
//      You should have received a copy of the GNU General Public License
//      along with this program; if not, write to the Free Software
//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//      MA 02110-1301, USA.

#include <stdio.h>

typedef long long ll;

int q[3000];
int l[2000];

int init()
{
    int f = 0, r = 0, ret = 0;
    const int limit = 1000000000;
    q[r++] = 4;
    q[r++] = 7;
    while (f < r)
    {
        l[ret++] = q[f];
        if ((ll)q[f] * 10 + 4 < limit)
        {
            q[r++] = q[f] * 10 + 4;
        }
        if ((ll)q[f] * 10 + 7 < limit)
        {
            q[r++] = q[f] * 10 + 7;
        }
        f++;
    }
    return ret;
}

int left_choice(int i, int left, int right)
{
    int a, b;
    if (i > 0)
    {
        if (l[i - 1] >= right)
        {
            return 0;
        }
        else if (l[i - 1] >= left)
        {
            a = l[i - 1] + 1;
        }
        else
        {
            a = left;
        }
        if (l[i] < left)
        {
            return 0;
        }
        else if (l[i] < right)
        {
            b = l[i];
        }
        else
        {
            b = right;
        }
        return b - a + 1;
    }
    else
    {
        if (l[i] < left)
        {
            return 0;
        }
        else if (l[i] < right)
        {
            return l[i] - left + 1;
        }
        else
        {
            return right - left + 1;
        }
    }
}

int right_choice(int i, int n, int left, int right)
{
    int a, b;
    if (i < n - 1)
    {
        if (l[i + 1] <= left)
        {
            return 0;
        }
        else if (l[i + 1] <= right)
        {
            b = l[i + 1] - 1;
        }
        else
        {
            b = right;
        }
        if (l[i] > right)
        {
            return 0;
        }
        else if (l[i] > left)
        {
            a = l[i];
        }
        else
        {
            a = left;
        }
        return b - a + 1;
    }
    else
    {
        if (l[i] > right)
        {
            return 0;
        }
        else if (l[i] > left)
        {
            return right - l[i] + 1;
        }
        else
        {
            return right - left + 1;
        }
    }
}

void func(int pl, int pr, int vl, int vr, int k, int n)
{
    double ans = 0.;
    int i, cp, cv;
    for (i = 0; i + k <= n; i++)
    {
        cp = left_choice(i, pl, pr);
        cv = right_choice(i + k - 1, n, vl, vr);
        ans += (double)cp / (double)(pr - pl + 1) * ((double)cv / (double)(vr - vl + 1));
        cp = right_choice(i + k - 1, n, pl, pr);
        cv = left_choice(i, vl, vr);
        ans += (double)cp / (double)(pr - pl + 1) * ((double)cv / (double)(vr - vl + 1));
    }
    printf("%.11lf\n", ans);
}

int main(int argc, char **argv)
{
    int pl, pr, vl, vr, k, n;
    n = init();
    while (scanf("%d%d%d%d%d", &pl, &pr, &vl, &vr, &k) == 5)
    {
        func(pl, pr, vl, vr, k, n);
    }
    return 0;
}

#include <stdio.h>
int checkIsLucky(int num){
    while(num>0){
        if(num%10!=4&&num%10!=7)return 0;
        num/=10;
    }
    return 1;
}
int nextNum(int num){
    int nextN;
    int count=1;
    int maxNextD=0;
    nextN=num;
    if(num>=777777777) return 1000000001;
    while(num>0){
        if(num%10==4){
            nextN+=count*3;
            nextN=nextN/(count)*count+maxNextD;
            break;
        }else{
            maxNextD*=10;
            maxNextD+=4;
            num/=10;
            count*=10;
        }
    }
    if(num>0) return nextN;
    else{
        maxNextD*=10;
        maxNextD+=4;
        return maxNextD;
    }
}

int max(int a,int b){
    if(a>b) return a;
    else return b;
}
int min(int a,int b){
    if(a>b) return b;
    else return a;
}
int kthNum(int begin,int k){
    int count=1;
    int rt=0,tmp=begin;
    while (tmp>0) {
        tmp/=10;
        rt*=10;
        rt+=4;
    }
    while(rt<begin)rt=nextNum(rt);
    for(;count<k;count++){
        rt=nextNum(rt);
    }
    return rt;
}
double lenthRt(unsigned a,unsigned b,unsigned lk1,unsigned lk2){
    int ma,mi;
    mi=max(a,lk1);
    ma=min(b,lk2);
    double kq;
    if(ma<mi) return 0;
    else {
        if(lk2==ma){
            kq=ma-mi;
            return kq;
        }

        kq= ma-mi+1;
        return kq;
    }
}
int main(){
    int pl,pr,vl,vr,k;
    int minN,maxN,lk1,lk2,i,after;
    double sum=0;

    double kq,mau;
    //pl=5;pr=6;
    //vl=8;vr=10;k=1;
    //printf("%d",nextNum(47));
    /*for(i=4;i<1000000000;i=nextNum(i)){
            printf("%d\n",i);

    }*/
    scanf("%d %d %d %d %d",&pl,&pr,&vl,&vr,&k);
    minN=min(pl,vl);
    maxN=max(pr,vr);

    //for p
    after=kthNum(pl,1);
    lk1= kthNum(pl,k);
    lk2= nextNum(lk1);
    i=pl;
    for(;i<=pr;){//xet tat ca cac chu so trong [pl+1,pr]

        sum+=lenthRt(vl,vr,lk1,lk2)*min(after-i+1,pr-i+1);
        //printf("%d to %d-> %d %d + them %lf*%d->%lf\n",i,after,lk1,lk2,lenthRt(vl,vr,lk1,lk2),min(after-i+1,pr-i+1),sum);

        i=after+1;
        after=nextNum(after);
        lk1=lk2;
        if(lk1>vr) break;
        lk2=nextNum(lk2);
    }

    //for p
    after=kthNum(vl,1);
    lk1= kthNum(vl,k);
    lk2= nextNum(lk1);
    i=vl;
    for(;i<=vr;){//xet tat ca cac chu so trong [pl+1,pr]

        sum+=lenthRt(pl,pr,lk1,lk2)*min(after-i+1,vr-i+1);
        //printf("%d to %d-> %d %d + them %lf*%d ->%lf\n",i,after,lk1,lk2,lenthRt(pl,pr,lk1,lk2),min(after-i+1,pr-i+1),sum);

        i=after+1;
        after=nextNum(after);
        lk1=lk2;
        if(lk1>pr) break;
        lk2=nextNum(lk2);
    }
    mau=(pr-pl+1);
    mau*=     (vr-vl+1);
    //printf("%lf %lf");
    //printf("%lf %lf\n",sum,mau);
    kq=sum/mau;
    printf("%.12lf",kq);
    return 0;
}

#include <stdio.h>
int checkIsLucky(int num){
    while(num>0){
        if(num%10!=4&&num%10!=7)return 0;
        num/=10;
    }
    return 1;
}
int nextNum(int num){
    int nextN;
    int count=1;
    int maxNextD=0;
    nextN=num;
    if(num>=777777777) return 1000000001;
    while(num>0){
        if(num%10==4){
            nextN+=count*3;
            nextN=nextN/(count)*count+maxNextD;
            break;
        }else{
            maxNextD*=10;
            maxNextD+=4;
            num/=10;
            count*=10;
        }
    }
    if(num>0) return nextN;
    else{
        maxNextD*=10;
        maxNextD+=4;
        return maxNextD;
    }
}

int max(int a,int b){
    if(a>b) return a;
    else return b;
}
int min(int a,int b){
    if(a>b) return b;
    else return a;
}
int kthNum(int begin,int k){
    int count=1;
    int rt=0,tmp=begin;
    while (tmp>0) {
        tmp/=10;
        rt*=10;
        rt+=4;
    }
    while(rt<begin)rt=nextNum(rt);
    for(;count<k;count++){
        rt=nextNum(rt);
    }
    return rt;
}
double lenthRt(unsigned a,unsigned b,unsigned lk1,unsigned lk2){
    int ma,mi;
    mi=max(a,lk1);
    ma=min(b,lk2);
    double kq;
    if(ma<mi) return 0;
    else {
        if(lk2==ma){
            kq=ma-mi;
            return kq;
        }

        kq= ma-mi+1;
        return kq;
    }
}
int main(){
    int pl,pr,vl,vr,k;
    int minN,maxN,lk1,lk2,i,after;
    double sum=0;

    double kq,mau;
    //pl=5;pr=6;
    //vl=8;vr=10;k=1;
    //printf("%d",nextNum(47));
    /*for(i=4;i<1000000000;i=nextNum(i)){
            printf("%d\n",i);

    }*/
    scanf("%d %d %d %d %d",&pl,&pr,&vl,&vr,&k);
    minN=min(pl,vl);
    maxN=max(pr,vr);

    //for p
    after=kthNum(pl,1);
    lk1= kthNum(pl,k);
    lk2= nextNum(lk1);
    i=pl;
    for(;i<=pr;){//xet tat ca cac chu so trong [pl+1,pr]

        sum+=lenthRt(vl,vr,lk1,lk2)*min(after-i+1,pr-i+1);
        //printf("%d to %d-> %d %d + them %lf*%d->%lf\n",i,after,lk1,lk2,lenthRt(vl,vr,lk1,lk2),min(after-i+1,pr-i+1),sum);

        i=after+1;
        after=nextNum(after);
        lk1=lk2;
        if(lk1>vr) break;
        lk2=nextNum(lk2);
    }

    //for p
    after=kthNum(vl,1);
    lk1= kthNum(vl,k);
    lk2= nextNum(lk1);
    i=vl;
    for(;i<=vr;){//xet tat ca cac chu so trong [pl+1,pr]
        if(vl==vr&&pl==pr&&pl==vr) break;
        sum+=lenthRt(pl,pr,lk1,lk2)*min(after-i+1,vr-i+1);
        //printf("%d to %d-> %d %d + them %lf*%d ->%lf\n",i,after,lk1,lk2,lenthRt(pl,pr,lk1,lk2),min(after-i+1,pr-i+1),sum);

        i=after+1;
        after=nextNum(after);
        lk1=lk2;
        if(lk1>pr) break;
        lk2=nextNum(lk2);
    }
    mau=(pr-pl+1);
    mau*=     (vr-vl+1);
    //printf("%lf %lf");
    //printf("%lf %lf\n",sum,mau);
    kq=sum/mau;

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

#include <stdio.h>
int checkIsLucky(unsigned int num){
    while(num>0){
        if(num%10!=4&&num%10!=7)return 0;
        num/=10;
    }
    return 1;
}
unsigned int nextNum(unsigned int num){
    unsigned int nextN;
    unsigned int count=1;
    unsigned int maxNextD=0;
    nextN=num;
    while(num>0){
        if(num%10==4){
            nextN+=count*3;
            nextN=nextN/(count)*count+maxNextD;
            break;
        }else{
            maxNextD*=10;
            maxNextD+=4;
            num/=10;
            count*=10;
        }
    }
    if(num>0) return nextN;
    else{
        maxNextD*=10;
        maxNextD+=4;
        return maxNextD;
    }
}

unsigned int max(unsigned int a,unsigned int b){
    if(a>b) return a;
    else return b;
}
unsigned int min(unsigned int a,unsigned int b){
    if(a>b) return b;
    else return a;
}
unsigned int kthNum(unsigned int begin,int k){
    int count=1;
    unsigned int rt=0,tmp=begin;
    while (tmp>0) {
        tmp/=10;
        rt*=10;
        rt+=4;
    }
    while(rt<begin)rt=nextNum(rt);
    for(;count<k;count++){
        rt=nextNum(rt);
    }
    return rt;
}
unsigned int lenthRt(unsigned a,unsigned b,unsigned lk1,unsigned lk2){
    unsigned int ma,mi;
    mi=max(a,lk1);
    ma=min(b,lk2);
    if(ma<mi) return 0;
    else return ma-mi+1;
}
int main(){
    unsigned int pl,pr,vl,vr,k;
    unsigned int minN,maxN,lk1,lk2,i;
    unsigned long long sum=0;
    double kq;
    //pl=5;pr=6;
    //vl=8;vr=10;k=1;
    //printf("%d",nextNum(47));
    scanf("%d %d %d %d %d",&pl,&pr,&vl,&vr,&k);
    minN=min(pl,vl);
    maxN=max(pr,vr);

    //for p
    lk1= kthNum(pl,k);
    lk2= nextNum(lk1);
    sum+=lenthRt(vl,vr,lk1,lk2);
        printf("%d %d %d %d %d\n",pl,lk1,lk2,lenthRt(vl,vr,lk1,lk2),sum);
    //xet pl

    for(i=pl+1;i<=pr;i++){//xet tat ca cac chu so trong [pl+1,pr]
        if(checkIsLucky(i-1)==1){
            lk1=lk2;
            lk2=nextNum(lk2);
        }
        printf("%d %d %d %d %d\n",i,lk1,lk2,lenthRt(vl,vr,lk1,lk2),sum);
        sum+=lenthRt(vl,vr,lk1,lk2);
    }

    //for v
    lk1= kthNum(vl,k);
    lk2= nextNum(lk1);
    sum+=lenthRt(pl,pr,lk1,lk2);
        printf("%d %d %d %d %d\n",vl,lk1,lk2,lenthRt(vl,vr,lk1,lk2),sum);
    //xet vl

    for(i=vl+1;i<=vr;i++){//xet tat ca cac chu so trong [pl+1,pr]
        if(checkIsLucky(i-1)==1){
            lk1=lk2;
            lk2=nextNum(lk2);

            sum+=lenthRt(pl,pr,lk1,lk2);
        }
        printf("%d %d %d %d %d\n",i,lk1,lk2,lenthRt(vl,vr,lk1,lk2),sum);
        sum+=lenthRt(vl,vr,lk1,lk2);
    }
    printf("%ld %ld\n",sum,((pr-pl+1)*(vr-vl+1)));
    kq=sum*1.0/((pr-pl+1)*(vr-vl+1));
    printf("%.12lf",kq);
    return 0;
}

#include <stdio.h>
int checkIsLucky(unsigned int num){
    while(num>0){
        if(num%10!=4&&num%10!=7)return 0;
        num/=10;
    }
    return 1;
}
unsigned int nextNum(unsigned int num){
    unsigned int nextN;
    unsigned int count=1;
    unsigned int maxNextD=0;
    nextN=num;
    while(num>0){
        if(num%10==4){
            nextN+=count*3;
            break;
        }else{
            maxNextD*=10;
            maxNextD+=4;
            num/=10;
            count*=10;
        }
    }
    if(num>0) return nextN;
    else{
        maxNextD*=10;
        maxNextD+=4;
        return maxNextD;
    }
}

unsigned int max(unsigned int a,unsigned int b){
    if(a>b) return a;
    else return b;
}
unsigned int min(unsigned int a,unsigned int b){
    if(a>b) return b;
    else return a;
}
unsigned int kthNum(unsigned int begin,int k){
    int count=1;
    unsigned int rt=0,tmp=begin;
    while (tmp>0) {
        tmp/=10;
        rt*=10;
        rt+=4;
    }
    while(rt<begin)rt=nextNum(rt);
    for(;count<k;count++){
        rt=nextNum(rt);
    }
    return rt;
}
unsigned int lenthRt(unsigned a,unsigned b,unsigned lk1,unsigned lk2){
    unsigned int ma,mi;
    mi=max(a,lk1);
    ma=min(b,lk2);
    if(ma<mi) return 0;
    else return ma-mi+1;
}
int main(){
    unsigned int pl,pr,vl,vr,k;
    unsigned int minN,maxN,lk1,lk2,i;
    unsigned long long sum=0;
    double kq;
    //pl=5;pr=6;
    //vl=8;vr=10;k=1;
    scanf("%d %d %d %d %d",&pl,&pr,&vl,&vr,&k);
    minN=min(pl,vl);
    maxN=max(pr,vr);

    //for p
    lk1= kthNum(pl,k);
    lk2= nextNum(lk1);
    sum+=lenthRt(vl,vr,lk1,lk2);
    //printf("%d %d %d\n",pl,lk1,lk2);
    //xet pl

    for(i=pl+1;i<=pr;i++){//xet tat ca cac chu so trong [pl+1,pr]
        if(checkIsLucky(i-1)==1){
            lk1=lk2;
            lk2=nextNum(lk2);
        }
        //printf("%d %d %d\n",i,lk1,lk2);
        sum+=lenthRt(vl,vr,lk1,lk2);
    }

    //for v
    lk1= kthNum(vl,k);
    lk2= nextNum(lk1);
    sum+=lenthRt(pl,pr,lk1,lk2);
        //printf("%d %d %d\n",vl,lk1,lk2);
    //xet vl

    for(i=vl+1;i<=vr;i++){//xet tat ca cac chu so trong [pl+1,pr]
        if(checkIsLucky(i-1)==1){
            lk1=lk2;
            lk2=nextNum(lk2);

            sum+=lenthRt(pl,pr,lk1,lk2);
        }
        //printf("%d %d %d\n",i,lk1,lk2);
        sum+=lenthRt(vl,vr,lk1,lk2);
    }
    kq=sum*1.0/((pr-pl+1)*(vr-vl+1));
    printf("%.12lf",kq);
    return 0;
}

#include <stdio.h>
int checkIsLucky(int num){
    while(num>0){
        if(num%10!=4&&num%10!=7)return 0;
        num/=10;
    }
    return 1;
}
int nextNum(int num){
    int nextN;
    int count=1;
    int maxNextD=0;
    nextN=num;
    if(num>=777777777) return 1000000000;
    while(num>0){
        if(num%10==4){
            nextN+=count*3;
            nextN=nextN/(count)*count+maxNextD;
            break;
        }else{
            maxNextD*=10;
            maxNextD+=4;
            num/=10;
            count*=10;
        }
    }
    if(num>0) return nextN;
    else{
        maxNextD*=10;
        maxNextD+=4;
        return maxNextD;
    }
}

int max(int a,int b){
    if(a>b) return a;
    else return b;
}
int min(int a,int b){
    if(a>b) return b;
    else return a;
}
int kthNum(int begin,int k){
    int count=1;
    int rt=0,tmp=begin;
    while (tmp>0) {
        tmp/=10;
        rt*=10;
        rt+=4;
    }
    while(rt<begin)rt=nextNum(rt);
    for(;count<k;count++){
        rt=nextNum(rt);
    }
    return rt;
}
int lenthRt(unsigned a,unsigned b,unsigned lk1,unsigned lk2){
    int ma,mi;
    mi=max(a,lk1);
    ma=min(b,lk2);
    if(ma<mi) return 0;
    else {
        if(lk2==ma) return ma-mi;
        return ma-mi+1;
    }
}
int main(){
    int pl,pr,vl,vr,k;
    int minN,maxN,lk1,lk2,i,after;
    unsigned long long sum=0;

    double kq,mau;
    //pl=5;pr=6;
    //vl=8;vr=10;k=1;
    //printf("%d",nextNum(47));
    /*for(i=4;i<1000000000;i=nextNum(i)){
            printf("%d\n",i);

    }*/
    scanf("%d %d %d %d %d",&pl,&pr,&vl,&vr,&k);
    minN=min(pl,vl);
    maxN=max(pr,vr);

    //for p
    after=kthNum(pl,1);
    lk1= kthNum(pl,k);
    lk2= nextNum(lk1);
    i=pl;
    for(;i<=pr;){//xet tat ca cac chu so trong [pl+1,pr]

        //printf("%d to %d-> %d %d + them %d*%d\n",i,after,lk1,lk2,lenthRt(vl,vr,lk1,lk2),min(after-i+1,pr-i+1));

        sum+=lenthRt(vl,vr,lk1,lk2)*min(after-i+1,pr-i+1);
        i=after+1;
        after=nextNum(after);
        lk1=lk2;
        if(lk1>vr) break;
        lk2=nextNum(lk2);
    }

    //for p
    after=kthNum(vl,1);
    lk1= kthNum(vl,k);
    lk2= nextNum(lk1);
    i=vl;
    for(;i<=vr;){//xet tat ca cac chu so trong [pl+1,pr]

        //printf("%d to %d-> %d %d + them %d*%d\n",i,after,lk1,lk2,lenthRt(pl,pr,lk1,lk2),min(after-i+1,pr-i+1));
        sum+=lenthRt(pl,pr,lk1,lk2)*min(after-i+1,vr-i+1);
        i=after+1;
        after=nextNum(after);
        lk1=lk2;
        if(lk1>vr) break;
        lk2=nextNum(lk2);
    }
    mau=(pr-pl+1);
    mau*=     (vr-vl+1);
    printf("%ld %ld\n",sum,mau);
    kq=sum/mau;
    printf("%.12lf",kq);
    return 0;
}

#include <stdio.h>
int checkIsLucky(unsigned int num){
    while(num>0){
        if(num%10!=4&&num%10!=7)return 0;
        num/=10;
    }
    return 1;
}
unsigned int nextNum(unsigned int num){
    unsigned int nextN;
    unsigned int count=1;
    unsigned int maxNextD=0;
    nextN=num;
    while(num>0){
        if(num%10==4){
            nextN+=count*3;
            nextN=nextN/(count)*count+maxNextD;
            break;
        }else{
            maxNextD*=10;
            maxNextD+=4;
            num/=10;
            count*=10;
        }
    }
    if(num>0) return nextN;
    else{
        maxNextD*=10;
        maxNextD+=4;
        return maxNextD;
    }
}

unsigned int max(unsigned int a,unsigned int b){
    if(a>b) return a;
    else return b;
}
unsigned int min(unsigned int a,unsigned int b){
    if(a>b) return b;
    else return a;
}
unsigned int kthNum(unsigned int begin,int k){
    int count=1;
    unsigned int rt=0,tmp=begin;
    while (tmp>0) {
        tmp/=10;
        rt*=10;
        rt+=4;
    }
    while(rt<begin)rt=nextNum(rt);
    for(;count<k;count++){
        rt=nextNum(rt);
    }
    return rt;
}
unsigned int lenthRt(unsigned a,unsigned b,unsigned lk1,unsigned lk2){
    unsigned int ma,mi;
    mi=max(a,lk1);
    ma=min(b,lk2);
    if(ma<mi) return 0;
    else {
        if(lk2==ma) return ma-mi;
        return ma-mi+1;
    }
}
int main(){
    unsigned int pl,pr,vl,vr,k;
    unsigned int minN,maxN,lk1,lk2,i,after;
    unsigned long long sum=0;
    double kq;
    //pl=5;pr=6;
    //vl=8;vr=10;k=1;
    //printf("%d",nextNum(47));
    scanf("%d %d %d %d %d",&pl,&pr,&vl,&vr,&k);
    minN=min(pl,vl);
    maxN=max(pr,vr);

    //for p
    after=kthNum(pl,1);
    lk1= kthNum(pl,k);
    lk2= nextNum(lk1);
    i=pl;
    for(;i<=pr;){//xet tat ca cac chu so trong [pl+1,pr]

        //printf("%d to %d-> %d %d + them %d*%d\n",i,after,lk1,lk2,lenthRt(vl,vr,lk1,lk2),(after-i+1));
        sum+=lenthRt(vl,vr,lk1,lk2)*(after-i+1);
        i=after+1;
        after=nextNum(after);
        lk1=lk2;
        if(lk1>vr) break;
        lk2=nextNum(lk2);
    }

    //for p
    after=kthNum(vl,1);
    lk1= kthNum(vl,k);
    lk2= nextNum(lk1);
    i=vl;
    for(;i<=vr;){//xet tat ca cac chu so trong [pl+1,pr]

        //printf("%d to %d-> %d %d + them %d*%d\n",i,after,lk1,lk2,lenthRt(vl,vr,lk1,lk2),(after-i+1));
        sum+=lenthRt(pl,pr,lk1,lk2)*(after-i+1);
        i=after+1;
        after=nextNum(after);
        lk1=lk2;
        if(lk1>vr) break;
        lk2=nextNum(lk2);
    }
    //    printf("%ld %ld\n",sum,((pr-pl+1)*(vr-vl+1)));
    kq=sum*1.0/((pr-pl+1)*(vr-vl+1));
    printf("%.12lf",kq);
    return 0;
}

#include <stdio.h>
int checkIsLucky(int num){
    while(num>0){
        if(num%10!=4&&num%10!=7)return 0;
        num/=10;
    }
    return 1;
}
int nextNum(int num){
    int nextN;
    int count=1;
    int maxNextD=0;
    nextN=num;
    if(num>=777777777) return 1000000001;
    while(num>0){
        if(num%10==4){
            nextN+=count*3;
            nextN=nextN/(count)*count+maxNextD;
            break;
        }else{
            maxNextD*=10;
            maxNextD+=4;
            num/=10;
            count*=10;
        }
    }
    if(num>0) return nextN;
    else{
        maxNextD*=10;
        maxNextD+=4;
        return maxNextD;
    }
}

int max(int a,int b){
    if(a>b) return a;
    else return b;
}
int min(int a,int b){
    if(a>b) return b;
    else return a;
}
int kthNum(int begin,int k){
    int count=1;
    int rt=0,tmp=begin;
    while (tmp>0) {
        tmp/=10;
        rt*=10;
        rt+=4;
    }
    while(rt<begin)rt=nextNum(rt);
    for(;count<k;count++){
        rt=nextNum(rt);
    }
    return rt;
}
double lenthRt(unsigned a,unsigned b,unsigned lk1,unsigned lk2){
    int ma,mi;
    mi=max(a,lk1);
    ma=min(b,lk2);
    double kq;
    if(ma<mi) return 0;
    else {
        if(lk2==ma){
            kq=ma-mi;
            return kq;
        }

        kq= ma-mi+1;
        return kq;
    }
}
int main(){
    int pl,pr,vl,vr,k;
    int minN,maxN,lk1,lk2,i,after;
    double sum=0;

    double kq,mau;
    //pl=5;pr=6;
    //vl=8;vr=10;k=1;
    //printf("%d",nextNum(47));
    /*for(i=4;i<1000000000;i=nextNum(i)){
            printf("%d\n",i);

    }*/
    scanf("%d %d %d %d %d",&pl,&pr,&vl,&vr,&k);
    minN=min(pl,vl);
    maxN=max(pr,vr);

    //for p
    after=kthNum(pl,1);
    lk1= kthNum(pl,k);
    lk2= nextNum(lk1);
    i=pl;
    for(;i<=pr;){//xet tat ca cac chu so trong [pl+1,pr]

        sum+=lenthRt(vl,vr,lk1,lk2)*min(after-i+1,pr-i+1);
        //printf("%d to %d-> %d %d + them %lf*%d->%lf\n",i,after,lk1,lk2,lenthRt(vl,vr,lk1,lk2),min(after-i+1,pr-i+1),sum);

        i=after+1;
        after=nextNum(after);
        lk1=lk2;
        if(lk1>vr) break;
        lk2=nextNum(lk2);
    }

    //for p
    after=kthNum(vl,1);
    lk1= kthNum(vl,k);
    lk2= nextNum(lk1);
    i=vl;
    for(;i<=vr;){//xet tat ca cac chu so trong [pl+1,pr]

        sum+=lenthRt(pl,pr,lk1,lk2)*min(after-i+1,vr-i+1);
        //printf("%d to %d-> %d %d + them %lf*%d ->%lf\n",i,after,lk1,lk2,lenthRt(pl,pr,lk1,lk2),min(after-i+1,pr-i+1),sum);

        i=after+1;
        after=nextNum(after);
        lk1=lk2;
        if(lk1>vr) break;
        lk2=nextNum(lk2);
    }
    mau=(pr-pl+1);
    mau*=     (vr-vl+1);
    //printf("%lf %lf");
    //printf("%lf %lf\n",sum,mau);
    kq=sum/mau;
    printf("%.12lf",kq);
    return 0;
}

#include <stdio.h>
int checkIsLucky(int num){
    while(num>0){
        if(num%10!=4&&num%10!=7)return 0;
        num/=10;
    }
    return 1;
}
int nextNum(int num){
    int nextN;
    int count=1;
    int maxNextD=0;
    nextN=num;
    if(num>=777777777) return 1000000001;
    while(num>0){
        if(num%10==4){
            nextN+=count*3;
            nextN=nextN/(count)*count+maxNextD;
            break;
        }else{
            maxNextD*=10;
            maxNextD+=4;
            num/=10;
            count*=10;
        }
    }
    if(num>0) return nextN;
    else{
        maxNextD*=10;
        maxNextD+=4;
        return maxNextD;
    }
}

int max(int a,int b){
    if(a>b) return a;
    else return b;
}
int min(int a,int b){
    if(a>b) return b;
    else return a;
}
int kthNum(int begin,int k){
    int count=1;
    int rt=0,tmp=begin;
    while (tmp>0) {
        tmp/=10;
        rt*=10;
        rt+=4;
    }
    while(rt<begin)rt=nextNum(rt);
    for(;count<k;count++){
        rt=nextNum(rt);
    }
    return rt;
}
double lenthRt(unsigned a,unsigned b,unsigned lk1,unsigned lk2){
    int ma,mi;
    mi=max(a,lk1);
    ma=min(b,lk2);
    double kq;
    if(ma<mi) return 0;
    else {
        if(lk2==ma){
            kq=ma-mi;
            return kq;
        }

        kq= ma-mi+1;
        return kq;
    }
}
int main(){
    int pl,pr,vl,vr,k;
    int minN,maxN,lk1,lk2,i,after;
    double sum=0;

    double kq,mau;
    //pl=5;pr=6;
    //vl=8;vr=10;k=1;
    //printf("%d",nextNum(47));
    /*for(i=4;i<1000000000;i=nextNum(i)){
            printf("%d\n",i);

    }*/
    scanf("%d %d %d %d %d",&pl,&pr,&vl,&vr,&k);
    minN=min(pl,vl);
    maxN=max(pr,vr);

    //for p
    after=kthNum(pl,1);
    lk1= kthNum(pl,k);
    lk2= nextNum(lk1);
    i=pl;
    for(;i<=pr;){//xet tat ca cac chu so trong [pl+1,pr]

        sum+=lenthRt(vl,vr,lk1,lk2)*min(after-i+1,pr-i+1);
        //printf("%d to %d-> %d %d + them %lf*%d->%lf\n",i,after,lk1,lk2,lenthRt(vl,vr,lk1,lk2),min(after-i+1,pr-i+1),sum);

        i=after+1;
        after=nextNum(after);
        lk1=lk2;
        if(lk1>vr) break;
        lk2=nextNum(lk2);
    }

    //for p
    after=kthNum(vl,1);
    lk1= kthNum(vl,k);
    lk2= nextNum(lk1);
    i=vl;
    for(;i<=vr;){//xet tat ca cac chu so trong [pl+1,pr]
        if(vl==vr||pl==pr) break;
        sum+=lenthRt(pl,pr,lk1,lk2)*min(after-i+1,vr-i+1);
        //printf("%d to %d-> %d %d + them %lf*%d ->%lf\n",i,after,lk1,lk2,lenthRt(pl,pr,lk1,lk2),min(after-i+1,pr-i+1),sum);

        i=after+1;
        after=nextNum(after);
        lk1=lk2;
        if(lk1>pr) break;
        lk2=nextNum(lk2);
    }
    mau=(pr-pl+1);
    mau*=     (vr-vl+1);
    //printf("%lf %lf");
    //printf("%lf %lf\n",sum,mau);
    kq=sum/mau;

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

#include <stdio.h>
int checkIsLucky(int num){
    while(num>0){
        if(num%10!=4&&num%10!=7)return 0;
        num/=10;
    }
    return 1;
}
int nextNum(int num){
    int nextN;
    int count=1;
    int maxNextD=0;
    nextN=num;
    if(num>=777777777) return 1000000000;
    while(num>0){
        if(num%10==4){
            nextN+=count*3;
            nextN=nextN/(count)*count+maxNextD;
            break;
        }else{
            maxNextD*=10;
            maxNextD+=4;
            num/=10;
            count*=10;
        }
    }
    if(num>0) return nextN;
    else{
        maxNextD*=10;
        maxNextD+=4;
        return maxNextD;
    }
}

int max(int a,int b){
    if(a>b) return a;
    else return b;
}
int min(int a,int b){
    if(a>b) return b;
    else return a;
}
int kthNum(int begin,int k){
    int count=1;
    int rt=0,tmp=begin;
    while (tmp>0) {
        tmp/=10;
        rt*=10;
        rt+=4;
    }
    while(rt<begin)rt=nextNum(rt);
    for(;count<k;count++){
        rt=nextNum(rt);
    }
    return rt;
}
int lenthRt(unsigned a,unsigned b,unsigned lk1,unsigned lk2){
    int ma,mi;
    mi=max(a,lk1);
    ma=min(b,lk2);
    if(ma<mi) return 0;
    else {
        if(lk2==ma) return ma-mi;
        return ma-mi+1;
    }
}
int main(){
    int pl,pr,vl,vr,k;
    int minN,maxN,lk1,lk2,i,after;
    unsigned long long sum=0;

    double kq,mau;
    //pl=5;pr=6;
    //vl=8;vr=10;k=1;
    //printf("%d",nextNum(47));
    /*for(i=4;i<1000000000;i=nextNum(i)){
            printf("%d\n",i);

    }*/
    scanf("%d %d %d %d %d",&pl,&pr,&vl,&vr,&k);
    minN=min(pl,vl);
    maxN=max(pr,vr);

    //for p
    after=kthNum(pl,1);
    lk1= kthNum(pl,k);
    lk2= nextNum(lk1);
    i=pl;
    for(;i<=pr;){//xet tat ca cac chu so trong [pl+1,pr]

        //printf("%d to %d-> %d %d + them %d*%d\n",i,after,lk1,lk2,lenthRt(vl,vr,lk1,lk2),min(after-i+1,pr-i+1));

        sum+=lenthRt(vl,vr,lk1,lk2)*min(after-i+1,pr-i+1);
        i=after+1;
        after=nextNum(after);
        lk1=lk2;
        if(lk1>vr) break;
        lk2=nextNum(lk2);
    }

    //for p
    after=kthNum(vl,1);
    lk1= kthNum(vl,k);
    lk2= nextNum(lk1);
    i=vl;
    for(;i<=vr;){//xet tat ca cac chu so trong [pl+1,pr]

        //printf("%d to %d-> %d %d + them %d*%d\n",i,after,lk1,lk2,lenthRt(pl,pr,lk1,lk2),min(after-i+1,pr-i+1));
        sum+=lenthRt(pl,pr,lk1,lk2)*min(after-i+1,vr-i+1);
        i=after+1;
        after=nextNum(after);
        lk1=lk2;
        if(lk1>vr) break;
        lk2=nextNum(lk2);
    }
    mau=(pr-pl+1);
    mau*=     (vr-vl+1);
    //printf("%ld %ld\n",sum,mau);
    kq=sum/mau;
    printf("%.12lf",kq);
    return 0;
}

/* practice with Dukkha */
#include <stdio.h>

#define A	1000000000

int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }

long long lucky(int i) {
	return i == 1 ? 0 : lucky(i / 2) * 10 + (i % 2 == 0 ? 4 : 7);
}

int intersect(int al, int ar, int bl, int br) {
	int l = max(al, bl);
	int r = min(ar, br);

	return max(r - l + 1, 0);
}

int main() {
	static int qq[1024];
	int ul, ur, vl, vr, k, cnt, i, j;
	long long a, cnt_;

	scanf("%d%d%d%d%d", &ul, &ur, &vl, &vr, &k);
	cnt = 0;
	qq[cnt++] = 0;
	for (i = 2; (a = lucky(i)) <= A; i++)
		qq[cnt++] = a;
	qq[cnt++] = A + 1;
	cnt_ = 0;
	for (i = 1; (j = i + k - 1) < cnt - 1; i++) {
		int pl = qq[i - 1] + 1, pr = qq[i];
		int ql = qq[j], qr = qq[j + 1] - 1;

		cnt_ += (long long) intersect(ul, ur, pl, pr) * intersect(vl, vr, ql, qr);
		cnt_ += (long long) intersect(ul, ur, ql, qr) * intersect(vl, vr, pl, pr);
	}
	printf("%.9f\n", (double) cnt_ / (ur - ul + 1) / (vr - vl + 1));
	return 0;
}

#include <stdio.h>
int checkIsLucky(unsigned int num){
    while(num>0){
        if(num%10!=4&&num%10!=7)return 0;
        num/=10;
    }
    return 1;
}
unsigned int nextNum(unsigned int num){
    unsigned int nextN;
    unsigned int count=1;
    unsigned int maxNextD=0;
    nextN=num;
    while(num>0){
        if(num%10==4){
            nextN+=count*3;
            nextN=nextN/(count)*count+maxNextD;
            break;
        }else{
            maxNextD*=10;
            maxNextD+=4;
            num/=10;
            count*=10;
        }
    }
    if(num>0) return nextN;
    else{
        maxNextD*=10;
        maxNextD+=4;
        return maxNextD;
    }
}

unsigned int max(unsigned int a,unsigned int b){
    if(a>b) return a;
    else return b;
}
unsigned int min(unsigned int a,unsigned int b){
    if(a>b) return b;
    else return a;
}
unsigned int kthNum(unsigned int begin,int k){
    int count=1;
    unsigned int rt=0,tmp=begin;
    while (tmp>0) {
        tmp/=10;
        rt*=10;
        rt+=4;
    }
    while(rt<begin)rt=nextNum(rt);
    for(;count<k;count++){
        rt=nextNum(rt);
    }
    return rt;
}
unsigned int lenthRt(unsigned a,unsigned b,unsigned lk1,unsigned lk2){
    unsigned int ma,mi;
    mi=max(a,lk1);
    ma=min(b,lk2);
    if(ma<mi) return 0;
    else return ma-mi+1;
}
int main(){
    unsigned int pl,pr,vl,vr,k;
    unsigned int minN,maxN,lk1,lk2,i;
    unsigned long long sum=0;
    double kq;
    //pl=5;pr=6;
    //vl=8;vr=10;k=1;
    //printf("%d",nextNum(47));
    scanf("%d %d %d %d %d",&pl,&pr,&vl,&vr,&k);
    minN=min(pl,vl);
    maxN=max(pr,vr);

    //for p
    lk1= kthNum(pl,k);
    lk2= nextNum(lk1);
    sum+=lenthRt(vl,vr,lk1,lk2);
       // printf("%d %d %d %d %d\n",pl,lk1,lk2,lenthRt(vl,vr,lk1,lk2),sum);
    //xet pl

    for(i=pl+1;i<=pr;i++){//xet tat ca cac chu so trong [pl+1,pr]
        if(checkIsLucky(i-1)==1){
            lk1=lk2;
            lk2=nextNum(lk2);
        }
        //printf("%d %d %d %d %d\n",i,lk1,lk2,lenthRt(vl,vr,lk1,lk2),sum);
        sum+=lenthRt(vl,vr,lk1,lk2);
    }

    //for v
    lk1= kthNum(vl,k);
    lk2= nextNum(lk1);
    sum+=lenthRt(pl,pr,lk1,lk2);
        //printf("%d %d %d %d %d\n",vl,lk1,lk2,lenthRt(vl,vr,lk1,lk2),sum);
    //xet vl

    for(i=vl+1;i<=vr;i++){//xet tat ca cac chu so trong [pl+1,pr]
        if(checkIsLucky(i-1)==1){
            lk1=lk2;
            lk2=nextNum(lk2);

            sum+=lenthRt(pl,pr,lk1,lk2);
        }
        //printf("%d %d %d %d %d\n",i,lk1,lk2,lenthRt(vl,vr,lk1,lk2),sum);
        sum+=lenthRt(vl,vr,lk1,lk2);
    }
//    printf("%ld %ld\n",sum,((pr-pl+1)*(vr-vl+1)));
    kq=sum*1.0/((pr-pl+1)*(vr-vl+1));
    printf("%.12lf",kq);
    return 0;
}

#include <stdio.h>
#define abs(a) (((a) < 0) ? (-(a)) : (a))
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

long long a[2500];
int m;

void
gen(int n, int i, long long num)
{
    if(i == n){
        a[m++] = num;
    } else {
        gen(n, i + 1, num * 10 + 4);
        gen(n, i + 1, num * 10 + 7);
    }
}

void
swap(long long *a, long long *b)
{
    long long tmp = *a;
    *a = *b;
    *b = tmp;
}

long long p_l, p_r, v_l, v_r, all, good, p1, p2;
int k;

int
main(void)
{
    a[m++] = 0;
    int i, j;
    for(i = 1; i <= 10; ++i)
        gen(i, 0, 0);
    scanf("%I64d%I64d%I64d%I64d%d", &p_l, &p_r, &v_l, &v_r, &k);
    all = (p_r - p_l + 1) * (v_r - v_l + 1);
    for(j = 0; j < 2; ++j){
        for(i = 1; i + k < m; ++i){
            long long l1 = max(a[i - 1], p_l),
                      r1 = min(a[i], p_r);
            if(l1 == a[i - 1]) ++l1;
            long long l2 = max(a[i + k - 1], v_l),
                      r2 = min(a[i + k], v_r);
            if(r2 == a[i + k]) --r2;
            if(l1 <= r1 && l2 <= r2){
                good += (r1 - l1 + 1) * (r2 - l2 + 1);
            }
        }
        swap(&p_l, &v_l);
        swap(&p_r, &v_r);
    }
    printf("%I64d.", good / all);
    good %= all;
    for(i = 0; i < 15; ++i){
        printf("%I64d", (good * 10LL) / all);
        good = (good * 10) % all;
    }
    return 0;
}

#include <stdio.h>
#define abs(a) (((a) < 0) ? (-(a)) : (a))
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

long long a[2500];
int m;

void
gen(int n, int i, long long num)
{
    if(i == n){
        a[m++] = num;
    } else {
        gen(n, i + 1, num * 10 + 4);
        gen(n, i + 1, num * 10 + 7);
    }
}

void
swap(long long *a, long long *b)
{
    long long tmp = *a;
    *a = *b;
    *b = tmp;
}

long long p_l, p_r, v_l, v_r, all, good, p1, p2;
int k;

int
main(void)
{
    a[m++] = 0;
    int i, j;
    for(i = 1; i <= 10; ++i)
        gen(i, 0, 0);
    scanf("%I64d%I64d%I64d%I64d%d", &p_l, &p_r, &v_l, &v_r, &k);
    all = (p_r - p_l + 1) * (v_r - v_l + 1);
    for(j = 0; j < 2; ++j){
        for(i = 1; i + k < m; ++i){
            long long l1 = max(a[i - 1], p_l),
                      r1 = min(a[i], p_r);
            if(l1 == a[i - 1]) ++l1;
            long long l2 = max(a[i + k - 1], v_l),
                      r2 = min(a[i + k], v_r);
            if(r2 == a[i + k]) --r2;
            if(l1 <= r1 && l2 <= r2){
                good += (r1 - l1 + 1) * (r2 - l2 + 1);
            }
        }
        swap(&p_l, &v_l);
        swap(&p_r, &v_r);
    }
    double ans = (double)good / all;
    printf("%.15lf", ans);
    return 0;
}