#include <bits/stdc++.h>
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)) <= 1000000000; i++) qq[cnt++] = a;
  qq[cnt++] = 1000000000 + 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;
}
