#include <bits/stdc++.h>
using namespace std;
long long a[3010];
long long cnt, pl, pr, vl, vr, k;
void dfs(int p, long long v) {
  if (p == 10)
    a[cnt++] = v;
  else {
    if (v) a[cnt++] = v;
    dfs(p + 1, v * 10 + 4);
    dfs(p + 1, v * 10 + 7);
  }
}
int main() {
  cin >> pl >> pr >> vl >> vr >> k;
  cnt = 1;
  dfs(0, 0);
  sort(a, a + cnt);
  double ans = 0;
  long long p = pr - pl + 1, v = vr - vl + 1;
  a[cnt] = (long long)1e18;
  for (int i = 1, j; i < cnt; i++)
    if (a[i] <= max(pr, vr) && (j = i + k - 1) < cnt && a[j] <= max(pr, vr)) {
      if (pl <= a[i] && pr >= a[i - 1]) {
        long long lef = max(pl, a[i - 1] + 1), rig = min((long long)pr, a[i]);
        long long ln = max(0ll, (rig - lef) + 1);
        long long rn =
            max(0ll, (min((long long)vr, a[j + 1] - 1) - max(vl, a[j])) + 1);
        ans += (double)ln / p * (double)rn / v;
      }
      if (vl <= a[i] && vr >= a[i - 1]) {
        long long ln =
            max(0ll, (min((long long)vr, a[i]) - max(vl, a[i - 1] + 1)) + 1);
        long long rn =
            max(0ll, (min((long long)pr, a[j + 1] - 1) - max(pl, a[j])) + 1);
        long long lef = max(pl, a[j]), rig = min((long long)pr, a[j + 1] - 1);
        ans += (double)ln / v * (double)rn / p;
      }
      if (k == 1 && a[i] >= pl && a[i] <= pr && a[i] >= vl && a[i] <= vr) {
        ans -= 1.0 / p * 1.0 / v;
      }
    }
  printf("%.10f\n", ans);
  return 0;
}
