#include <bits/stdc++.h>
using namespace std;
int ar[2000], ind;
int init() {
  ar[0] = 0;
  ind = 1;
  char tmp[10];
  int ind2;
  for (int i = 1; i <= 9; i++) {
    for (int j = i; j >= 0; j--) {
      ind2 = 0;
      tmp[i] = 0;
      while (ind2 < j) tmp[ind2++] = '4';
      while (ind2 < i) tmp[ind2++] = '7';
      do {
        sscanf(tmp, "%d", &ar[ind++]);
      } while (next_permutation(tmp, tmp + i));
    }
  }
  ar[ind] = 1000000001;
  sort(ar, ar + ind);
  return 0;
}
int solve() {
  int pl, pr, vl, vr, k;
  scanf("%d %d %d %d %d", &pl, &pr, &vl, &vr, &k);
  int cur = 0;
  long long cnt = 0;
  int l1, l2, u1, u2, kak1, kak2;
  long long pp, vv;
  for (int i = 1; i < ind; i++) {
    if (i + k > ind) break;
    l1 = ar[i - 1] + 1;
    l2 = ar[i];
    u1 = ar[i + k - 1];
    u2 = ar[i + k] - 1;
    pp = min(l2, pr) - max(l1, pl) + 1;
    if (pp < 0) pp = 0;
    vv = min(u2, vr) - max(u1, vl) + 1;
    if (vv < 0) vv = 0;
    cnt += pp * vv;
    pp = min(u2, pr) - max(u1, pl) + 1;
    if (pp < 0) pp = 0;
    vv = min(l2, vr) - max(l1, vl) + 1;
    if (vv < 0) vv = 0;
    cnt += pp * vv;
    kak1 = max(l1, u1);
    kak2 = min(u2, l2);
    pp = min(kak2, pr) - max(kak1, pl) + 1;
    if (pp < 0) pp = 0;
    vv = min(kak2, vr) - max(kak1, vl) + 1;
    if (vv < 0) vv = 0;
    cnt -= pp * vv;
  }
  long long all1 = (pr - pl + 1);
  long long all2 = (vr - vl + 1);
  long long all = all1 * all2;
  double sol = 1.0 * cnt / all;
  if (sol > 1.0) sol = 1.0;
  if (sol < 0) sol = 0.0;
  printf("%.12lf\n", sol);
  return 0;
}
int main() {
  init();
  solve();
  return 0;
}
