#include <bits/stdc++.h>
using namespace std;
vector<int> vi;
void f(long long int x) {
  if (x > 1e9) return;
  vi.push_back(x);
  f(x * 10 + 4);
  f(x * 10 + 7);
}
int main() {
  f(4), f(7);
  double ans = 0;
  int vl, vr, pr, pl, k;
  cin >> pl >> pr >> vl >> vr >> k;
  sort(vi.begin(), vi.end());
  for (int i = 0; i < (int)vi.size(); i++) {
    int a, b = 1e9, x = 1, y;
    if (i + k - 1 < (int)vi.size()) {
      a = vi[i + k - 1];
      if (i + k < (int)vi.size()) b = vi[i + k] - 1;
      y = vi[i];
      if (i - 1 > -1) x = vi[i - 1] + 1;
      if (max(a, vl) <= min(b, vr) && max(x, pl) <= min(y, pr))
        ans += (min(b, vr) - max(a, vl) + 1.0) / (vr - vl + 1) *
               (min(y, pr) - max(x, pl) + 1.0) / (pr - pl + 1);
      if (max(a, pl) <= min(b, pr) && max(x, vl) <= min(y, vr))
        ans += (min(b, pr) - max(a, pl) + 1.0) / (pr - pl + 1) *
               (min(y, vr) - max(x, vl) + 1.0) / (vr - vl + 1);
    }
  }
  if (k == 1 && max(pl, vl) <= min(vr, pr)) {
    ans -= (1.0 / (pr - pl + 1) * 1.0 / (vr - vl + 1)) *
           (upper_bound(vi.begin(), vi.end(), min(vr, pr)) -
            lower_bound(vi.begin(), vi.end(), max(pl, vl)) + 0.0);
  }
  printf("%.10f\n", ans);
  return 0;
}
