#include <bits/stdc++.h>
using namespace std;
long long p[1505], tot, p1, p2, v1, v2, k;
;
void dfs(long long x) {
  if (x > 1e9) return;
  p[tot++] = x;
  dfs(x * 10 + 4);
  dfs(x * 10 + 7);
}
int main() {
  scanf("%I64d%I64d%I64d%I64d%I64d", &p1, &p2, &v1, &v2, &k);
  tot = 0;
  dfs(0);
  sort(p, p + tot);
  p[tot] = 999999999;
  p[tot + 1] = 999999999;
  long long ans = 0;
  for (long long i = 1; i < tot; i++) {
    if (i + k - 1 > tot) break;
    long long x = p[i], y = p[i + k - 1];
    if (y > v2 && y > p2) break;
    long long l = 0, r = 0;
    l = max(l, min(p[k + i] - 1, v2) - max(v1, y) + 1);
    r = max(r, min(x, p2) - max(p1, p[i - 1] + 1) + 1);
    ans += l * r;
    l = r = 0;
    l = max(l, min(p[k + i] - 1, p2) - max(p1, y) + 1);
    r = max(r, min(x, v2) - max(v1, p[i - 1] + 1) + 1);
    ans += l * r;
    if (k == 1) {
      l = r = 0;
      l = max(l, min(p2, p[i]) - max(p1, p[i]) + 1);
      r = max(r, min(v2, p[i]) - max(v1, p[i]) + 1);
      ans -= l * r;
    }
  }
  double s = ans * 1.0 / ((p2 - p1 + 1) * (v2 - v1 + 1));
  printf("%.9lf\n", s);
  return 0;
}
