#include <bits/stdc++.h>
using namespace std;
vector<int> V;
void dfs(long long x) {
  if (x < 1000000000) {
    V.push_back(x);
    dfs(x * 10 + 4);
    dfs(x * 10 + 7);
  }
}
int main() {
  dfs(0);
  V.push_back(INT_MAX);
  sort(V.begin(), V.end());
  int pl, pr, vl, vr, k;
  cin >> pl >> pr >> vl >> vr >> k;
  double cnt = 0;
  double all = ((vr - vl) + 1.0) * ((pr - pl) + 1.0);
  for (int i = 1; i < V.size() - k; i++) {
    int hll = V[i - 1] + 1;
    int hl = V[i];
    int hr = V[(i + k) - 1];
    int hrr = V[(i + k)] - 1;
    if (pl <= hl && pr >= hll && vl <= hrr && vr >= hr) {
      cnt += (min(pr, hl) - max(pl, hll) + 1.0) *
             (min(vr, hrr) - max(vl, hr) + 1.0);
    }
    if (vl <= hl && vr >= hll && pl <= hrr && pr >= hr) {
      cnt += (min(vr, hl) - max(vl, hll) + 1.0) *
             (min(pr, hrr) - max(pl, hr) + 1.0);
      if (k == 1) cnt -= 1.0;
    }
  }
  printf("%.12f", cnt / all);
exit:
  return (0);
}
