#include <bits/stdc++.h>
using namespace std;
template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
long long pl, pr, vl, vr;
int k;
long long inter(long long a, long long b, long long c, long long d) {
  return max(0LL, min(b, d) - max(a, c) + 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> pl >> pr >> vl >> vr >> k;
  long double ans = 0;
  vector<long long> lucky;
  for (int len = (0); len < (11); len++) {
    for (int x = (0); x < ((1 << len)); x++) {
      long long y = 0;
      for (int i = (0); i < (len); i++) {
        if ((x >> i) & 1) {
          y = y * 10 + 4;
        } else {
          y = y * 10 + 7;
        }
      }
      lucky.push_back(y);
    }
  }
  sort((lucky).begin(), (lucky).end());
  int n = ((int)(lucky).size());
  for (int i = (1); i < (n - k); i++) {
    int j = i + k;
    ans += 1.0 * inter(pl, pr, lucky[i - 1] + 1, lucky[i]) *
           inter(vl, vr, lucky[j - 1], lucky[j] - 1);
    ans += 1.0 * inter(vl, vr, lucky[i - 1] + 1, lucky[i]) *
           inter(pl, pr, lucky[j - 1], lucky[j] - 1);
    if (k == 1 && pl <= lucky[i] && lucky[i] <= pr && vl <= lucky[i] &&
        lucky[i] <= vr)
      ans--;
  }
  ans /= 1.0 * (pr - pl + 1) * (vr - vl + 1);
  cout << fixed << setprecision(11) << ans << '\n';
}
