#include <bits/stdc++.h>
using namespace std;
vector<int> l;
long long mini, maxi;
long long cur;
void rec(long long cur) {
  if (cur <= maxi) {
    if (cur >= mini) l.push_back(cur);
  } else
    return;
  rec(cur * 10 + 4);
  rec(cur * 10 + 7);
}
void genLucky(int a, int b) {
  mini = a;
  maxi = b;
  l.clear();
  rec(0);
  l.push_back(a - 1);
  l.push_back(b + 1);
  sort(l.begin(), l.end());
}
long double prob(int pa, int pb, int ia, int ib) {
  int s = max(pa, ia);
  int e = min(pb, ib);
  if (s > e) return 0.0;
  long double res = e - s + 1.0;
  res /= (ib - ia + 1);
  return res;
}
int main() {
  int i, j;
  int pl, pr, vl, vr, k;
  cin >> pl >> pr >> vl >> vr >> k;
  genLucky(min(pl, vl), max(pr, vr));
  long double res = 0.0;
  if (k == 1) {
    for (i = 0; i + 2 < l.size(); ++i) {
      res += prob(l[i] + 1, l[i + 1], pl, pr) *
             prob(l[i + k] + 1, l[i + k + 1] - 1, vl, vr);
      res += prob(l[i] + 1, l[i + 1] - 1, pl, pr) *
             prob(l[i + k], l[i + k], vl, vr);
      res += prob(l[i] + 1, l[i + 1], vl, vr) *
             prob(l[i + k] + 1, l[i + k + 1] - 1, pl, pr);
      res += prob(l[i] + 1, l[i + 1] - 1, vl, vr) *
             prob(l[i + k], l[i + k], pl, pr);
      res +=
          prob(l[i + 1], l[i + 1], pl, pr) * prob(l[i + 1], l[i + 1], vl, vr);
    }
  } else {
    for (i = 0; i + k + 1 < l.size(); ++i) {
      res += prob(l[i] + 1, l[i + 1], pl, pr) *
             prob(l[i + k], l[i + k + 1] - 1, vl, vr);
      res += prob(l[i] + 1, l[i + 1], vl, vr) *
             prob(l[i + k], l[i + k + 1] - 1, pl, pr);
    }
  }
  printf("%.12lf\n", (double)res);
  return 0;
}
