#include <bits/stdc++.h>
using namespace std;
vector<long long> lucky;
void backtrack(long long num) {
  if (num > 10000000000) return;
  lucky.push_back(num);
  backtrack(num * 10 + 4);
  backtrack(num * 10 + 7);
}
int main() {
  backtrack(0);
  sort(lucky.begin(), lucky.end());
  pair<long long, long long> P, V;
  int k;
  cin >> P.first >> P.second;
  cin >> V.first >> V.second;
  cin >> k;
  long long denominator =
      1LL * (P.second - P.first + 1) * (V.second - V.first + 1);
  long long numerator = 0;
  for (int i = k; i + 1 < (int)lucky.size(); i++) {
    long long pLo = max(lucky[i - k] + 1, P.first);
    long long pHi = min(lucky[i - k + 1], P.second);
    long long vLo = max(lucky[i], V.first);
    long long vHi = min(lucky[i + 1] - 1, V.second);
    vLo = max(vLo, max(pLo, pHi));
    long long yo = 1LL * max(0LL, pHi - pLo + 1) * max(0LL, vHi - vLo + 1);
    numerator += yo;
    pLo = max(lucky[i], P.first);
    pHi = min(lucky[i + 1] - 1, P.second);
    vLo = max(lucky[i - k] + 1, V.first);
    vHi = min(lucky[i - k + 1], V.second);
    pLo = max(pLo, max(vLo, vHi));
    yo = 1LL * max(0LL, pHi - pLo + 1) * max(0LL, vHi - vLo + 1);
    numerator += yo;
  }
  if (k == 1)
    for (int i = 0; i < (int)lucky.size(); i++)
      if (lucky[i] >= max(P.first, V.first) &&
          lucky[i] <= min(P.second, V.second))
        numerator -= 1;
  printf("%.9lf\n", (1.0 * numerator) / denominator);
  return 0;
}
