#include <bits/stdc++.h>
int a, b, c, d, k;
int get(int a, int b, int l, int r) {
  if (a > r || b < l) {
    return 0;
  }
  return std::min(r, b) - std::max(l, a) + 1;
}
int main() {
  scanf("%d%d%d%d%d", &a, &b, &c, &d, &k);
  std::queue<int> q;
  std::vector<int> vt(0);
  q.push(0);
  while (q.size()) {
    int cur = q.front();
    q.pop();
    vt.push_back(cur);
    if (cur < (int)1e8) {
      q.push(cur * 10 + 4);
      q.push(cur * 10 + 7);
    }
  }
  vt.push_back(int(2e9));
  int size = vt.size() - 2;
  long long count = 0;
  for (int i = 1; i + k - 1 <= size; i++) {
    for (int j = 0; j <= 1; j++) {
      count += 1ll * get(a, b, vt[i - 1] + 1, vt[i]) *
               get(c, d, vt[i + k - 1], vt[i + k] - 1);
      if (a == c && b == d && a == b) {
      }
      std::swap(a, c);
      std::swap(b, d);
    }
    if (k == 1) {
      if (a <= vt[i] && b >= vt[i] && c <= vt[i] && d >= vt[i]) {
        count--;
      }
    }
  }
  printf("%.10f\n", 1.0 * count / ((b - a + 1.0) * (d - c + 1.0)));
  return 0;
}
