#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  return (b == 0) ? a : gcd(b, a % b);
}
template <class T>
T lcm(T a, T b) {
  return a * (b / gcd(a, b));
}
using namespace std;
vector<long long> L;
map<long long, bool> mapa;
void go(long long now) {
  if (now > 1000000000LL) return;
  L.push_back(now);
  go(now * 10LL + 4LL);
  go(now * 10LL + 7LL);
}
int main() {
  go(0);
  L.push_back(1000000000LL);
  sort(L.begin(), L.end());
  int len = L.size();
  long long p1, pr, v1, vr, k;
  while (cin >> p1 >> pr >> v1 >> vr >> k) {
    long long tot = 0;
    for (int i = 1; i < len - 1; i++) {
      long long temp = 0;
      if (p1 <= L[i] && pr >= L[i - 1] + 1 && v1 <= L[i + k] - 1 &&
          L[i + k - 1] <= vr) {
        temp = min(L[i], pr) - max(p1, L[i - 1] + 1LL) + 1LL;
        temp *= (min(vr, L[i + k] - 1LL) - max(v1, L[i + k - 1]) + 1LL);
      }
      tot += temp;
      temp = 0;
      swap(v1, p1);
      swap(vr, pr);
      if (p1 <= L[i] && pr >= L[i - 1] + 1 && v1 <= L[i + k] - 1 &&
          L[i + k - 1] <= vr) {
        temp = min(L[i], pr) - max(p1, L[i - 1] + 1LL) + 1LL;
        temp *= (min(vr, L[i + k] - 1LL) - max(v1, L[i + k - 1]) + 1LL);
        if (temp > 0 && k == 1) temp--;
      }
      tot += temp;
      swap(v1, p1);
      swap(vr, pr);
    }
    double ans =
        (double)tot / (double)(vr - v1 + 1LL) / (double)(pr - p1 + 1LL);
    printf("%.9lf\n", ans);
  }
  return 0;
}
