#include <bits/stdc++.h>
int pl, pr, vl, vr, k;
long long Calculate(int al, int ar, int bl, int br) {
  if (pl > al) al = pl;
  if (pr < ar) ar = pr;
  if (vl > bl) bl = vl;
  if (vr < br) br = vr;
  if (ar < al || br < bl) return 0;
  return (long long)(ar - al + 1) * (br - bl + 1);
}
int main() {
  int lucky[1024], n = 0;
  lucky[0] = 0;
  ++n;
  for (int i = 0; i < n; ++i) {
    if (lucky[i] > 100000000) continue;
    lucky[n++] = lucky[i] * 10 + 4;
    lucky[n++] = lucky[i] * 10 + 7;
  }
  lucky[n] = 1000000001;
  while (~scanf("%d %d %d %d %d", &pl, &pr, &vl, &vr, &k)) {
    long long total = (long long)(pr - pl + 1) * (vr - vl + 1), ways = 0;
    for (int i = 1; i <= n - k; ++i) {
      ways += Calculate(lucky[i - 1] + 1, lucky[i], lucky[i + k - 1],
                        lucky[i + k] - 1);
      ways += Calculate(lucky[i + k - 1], lucky[i + k] - 1, lucky[i - 1] + 1,
                        lucky[i]);
      if (k == 1) ways -= Calculate(lucky[i], lucky[i], lucky[i], lucky[i]);
    }
    printf("%0.10lf\n", (double)ways / total);
  }
  return 0;
}
