#include <bits/stdc++.h>
using namespace std;
void cal(long long l, long long r, long long* array1, long long* array2) {
  long long pre = 0LL;
  long long cnt = 0LL;
  memset(array1, 0LL, sizeof(array1));
  memset(array2, 0LL, sizeof(array2));
  for (int bit = 1; bit <= 10; ++bit) {
    for (int i = 0; i < (1 << bit); ++i) {
      long long cur = 0LL;
      for (int j = bit - 1; j >= 0; --j) {
        if ((1 << j) & i) {
          cur = cur * 10LL + 7LL;
        } else {
          cur = cur * 10LL + 4LL;
        }
      }
      if (cur < l) {
        pre = cur;
        cnt++;
      } else {
        if (cur > r && pre < l) {
          array1[cnt] = r - l + 1;
          array2[cnt] = r - l + 1;
        } else {
          long long tl, tr;
          tl = max(pre, l);
          tr = min(cur - 1, r);
          if (tl <= tr) {
            array1[cnt] = tr - tl + 1;
          }
          tl = max(pre + 1, l);
          tr = min(cur, r);
          if (tl <= tr) {
            array2[cnt] = tr - tl + 1;
          }
        }
        pre = cur;
        cnt++;
      }
    }
  }
}
int main() {
  long long pl, pr, vl, vr, k;
  long long p1[2000], p2[2000], v1[2000], v2[2000];
  while (cin >> pl >> pr >> vl >> vr >> k) {
    cal(pl, pr, p1, p2);
    cal(vl, vr, v1, v2);
    long long ans = 0LL;
    for (int num = 1024; num >= k; --num) {
      ans += v1[num] * p2[num - k];
      ans += p1[num] * v2[num - k];
      if (k == 1) {
        if (v1[num] * p2[num - k] > 0 && p1[num] * v2[num - k] > 0) {
          ans--;
        }
      }
    }
    double total = (double)((pr - pl + 1) * (vr - vl + 1));
    printf("%.10lf\n", (double)ans / total);
  }
  return 0;
}
