#include <bits/stdc++.h>
using namespace std;
int pl, pr;
int vl, vr;
int k;
vector<int> v;
int T = 100000000;
void Fun(int x) {
  if (x != 0) v.push_back(x);
  if (x >= T) return;
  Fun(x * 10 + 4);
  Fun(x * 10 + 7);
}
double ans;
double Prob(int l, int r, int len) {
  if (l > r) return 0;
  return (r - l + 1) / (double)len;
}
void Solve(int l, int r, int bl, int br) {
  double res1, res2, res3;
  if (l >= pl && r <= vr) {
    res1 = Prob(max(pl, bl + 1), min(pr, l), pr - pl + 1) *
           Prob(max(vl, r), min(vr, br - 1), vr - vl + 1);
  } else {
    res1 = 0;
  }
  if (l >= vl && r <= pr) {
    res2 = Prob(max(vl, bl + 1), min(vr, l), vr - vl + 1) *
           Prob(max(pl, r), min(pr, br - 1), pr - pl + 1);
  } else {
    res2 = 0;
  }
  if (k == 1 && vl <= l && l <= vr && pl <= l && l <= pr) {
    res3 = Prob(l, l, pr - pl + 1) * Prob(l, l, vr - vl + 1);
  } else {
    res3 = 0;
  }
  ans += res1 + res2 - res3;
}
int main() {
  int i;
  scanf("%d %d %d %d %d", &pl, &pr, &vl, &vr, &k);
  T = min(T, max(pr, vr));
  Fun(0);
  v.push_back(0);
  v.push_back(1000000000);
  sort(v.begin(), v.end());
  ans = 0;
  for (i = 1; i <= (int)v.size() - k - 1; i++) {
    Solve(v[i], v[i + k - 1], v[i - 1], v[i + k]);
  }
  printf("%.12lf\n", ans);
  return 0;
}
