#include <bits/stdc++.h>
using namespace std;
int pl, pr, vl, vr, k;
set<long long> __47;
void gen(long long n, int len) {
  if (len == 10) return;
  __47.insert(n);
  gen(n * 10LL + 4LL, len + 1);
  gen(n * 10LL + 7LL, len + 1);
}
long long calc(long long l1, long long r1, long long l2, long long r2) {
  return max(0LL, min(r1, r2) - max(l1, l2) + 1LL);
}
int main() {
  gen(0, 0);
  vector<long long> prt(__47.begin(), __47.end());
  cin >> pl >> pr >> vl >> vr >> k;
  long long tot = (pr - pl + 1LL) * (1LL + vr - vl), sum = 0;
  for (int i = k; i <= (int)prt.size() - 1; i++) {
    sum += calc(pl, pr, prt[i - k] + 1LL, prt[i - k + 1]) *
           calc(vl, vr, prt[i], prt[i + 1] - 1LL);
    sum += calc(vl, vr, prt[i - k] + 1LL, prt[i - k + 1]) *
           calc(pl, pr, prt[i], prt[i + 1] - 1LL);
    if (k == 1)
      sum -= calc(vl, vr, prt[i], prt[i]) * calc(pl, pr, prt[i], prt[i]);
  }
  cout << fixed << setprecision(12) << 1.0 * sum / tot << endl;
}
