#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, w = 0;
  char ch = getchar();
  while (!isdigit(ch)) w |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + ch - '0', ch = getchar();
  return w ? -x : x;
}
long long ans, a, b, c, d, k, ok[999999], tot;
void dfs(long long k, long long t) {
  ok[++tot] = t;
  if (t * 10 + 4 > 1e9) return;
  dfs(k + 1, t * 10 + 4);
  dfs(k + 1, t * 10 + 7);
}
long long calc(long long l, long long r, long long x, long long y) {
  long long L = max(l, x), R = min(y, r);
  return max(R - L + 1, 0ll);
}
signed main() {
  a = read(), b = read(), c = read(), d = read(), k = read();
  tot = -1;
  dfs(0, 0);
  ok[++tot] = 0x3f3f3f3f;
  sort(ok + 1, ok + 1 + tot);
  for (long long i = 1; i + k <= tot; ++i)
    ans += calc(a, b, ok[i - 1] + 1, ok[i]) *
           calc(c, d, ok[i + k - 1], ok[i + k] - 1);
  for (long long i = 1; i + k <= tot; ++i)
    ans += calc(c, d, ok[i - 1] + 1, ok[i]) *
           calc(a, b, ok[i + k - 1], ok[i + k] - 1);
  if (k == 1)
    for (long long i = 1; i < tot; ++i)
      if (calc(a, b, ok[i], ok[i]) && calc(c, d, ok[i], ok[i])) --ans;
  printf("%.15lf", 1.0 * ans / ((d - c + 1) * (b - a + 1)));
  return 0;
}
