#include <bits/stdc++.h>
using namespace std;
template <class _T>
inline string tostr(const _T& a) {
  ostringstream os("");
  os << a;
  return os.str();
}
long long ar, br, al, bl, k;
vector<long long> v;
void rec1(long long x) {
  if (x > br && x > ar) return;
  if (x) v.push_back(x);
  rec1(x * 10 + 4);
  rec1(x * 10 + 7);
}
long double prob(long long L, long long R, long long LL, long long RR) {
  if (R < LL || L > RR) return 0;
  if (L < LL) L = LL;
  if (R > RR) R = RR;
  return ((R - L + 1) * 1.0) / ((RR - LL + 1) * 1.0);
}
int main() {
  cout.flags(ios::fixed);
  cout.precision(15);
  cin >> al >> ar >> bl >> br >> k;
  v.push_back(0);
  rec1(0);
  v.push_back(max(ar, br) + 1);
  long double p = 0;
  sort(v.begin(), v.end());
  for (int i = 1; i < v.size(); i++) {
    if (i + k >= v.size()) {
      break;
    }
    p += prob(v[i - 1] + 1, v[i], al, ar) *
         prob(v[i + k - 1], v[i + k] - 1, bl, br);
    p += prob(v[i - 1] + 1, v[i], bl, br) *
         prob(v[i + k - 1], v[i + k] - 1, al, ar);
    if (k == 1) {
      p -= prob(v[i], v[i], al, ar) * prob(v[i + k - 1], v[i + k - 1], bl, br);
    }
  }
  cout << p;
  return 0;
}
