#include <bits/stdc++.h>
using namespace std;
int luckynum[100005];
int pl, pr, vl, vr, k;
int cnt = 0;
int frc[10] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000};
void dfs(int now, int cur) {
  luckynum[cnt++] = now;
  if (cur == 9) return;
  dfs(now + 4 * frc[cur], cur + 1);
  dfs(now + 7 * frc[cur], cur + 1);
}
int cover(int l1, int r1, int l2, int r2) {
  if (r1 < l2 || r2 < l1) return 0;
  return min(r1, r2) - max(l1, l2) + 1;
}
bool ok(int x) { return x >= pl && x <= pr && x >= vl && x <= vr; }
int main() {
  dfs(4, 1);
  dfs(7, 1);
  sort(luckynum, luckynum + cnt);
  while (cin >> pl >> pr >> vl >> vr >> k) {
    int l = min(pl, vl);
    int r = max(pr, vr);
    int s = lower_bound(luckynum, luckynum + cnt, l) - luckynum;
    int t = upper_bound(luckynum, luckynum + cnt, r) - luckynum;
    int sn = t - s;
    if (sn < k) {
      puts("0.000000000");
      continue;
    }
    int ll, rr, lr, rl;
    long long ans = 0;
    for (int i = s; i + k <= t; i++) {
      if (i == s)
        ll = l;
      else
        ll = luckynum[i - 1] + 1;
      if (i + k == t)
        rr = r;
      else
        rr = luckynum[i + k] - 1;
      if (k == 1)
        lr = luckynum[i], rl = luckynum[i + k - 1];
      else
        lr = luckynum[i], rl = luckynum[i + k - 1];
      int a = cover(pl, pr, ll, lr);
      int b = cover(vl, vr, rl, rr);
      ans += (long long)a * b;
      a = cover(pl, pr, rl, rr);
      b = cover(vl, vr, ll, lr);
      ans += (long long)a * b;
      if (k == 1) ans -= ok(luckynum[i]);
    }
    double res = 1.0 * ans / (pr - pl + 1) / (vr - vl + 1);
    printf("%.9lf\n", res);
  }
  return 0;
}
