#include <bits/stdc++.h>
using namespace std;
const int MX = (int)1e9 + 10000;
vector<long long> lucky;
void gen(long long c) {
  lucky.push_back(c);
  if (c * 10 + 4 < MX) gen(c * 10 + 4);
  if (c * 10 + 7 < MX) gen(c * 10 + 7);
}
double prob(long long a, long long b, long long c, long long d) {
  c = max(c, a);
  d = min(d, b);
  if (c > d) return 0;
  return (d - c + 1.0) / (b - a + 1.0);
}
void run() {
  lucky.clear();
  gen(0);
  lucky.push_back(MX);
  sort((lucky).begin(), (lucky).end());
  long long pl, pr, vl, vr, k;
  cin >> pl >> pr >> vl >> vr >> k;
  double ans = 0;
  int n = lucky.size();
  for (int i = 1; i < n - 1; i++) {
    ans +=
        prob(pl, pr, lucky[i], lucky[i]) *
        (k == 1 ? prob(vl, vr, lucky[i - 1] + 1, lucky[i + 1] - 1)
                : (i + k < n ? prob(vl, vr, lucky[i + k - 1], lucky[i + k] - 1)
                             : 0) +
                      (i >= k ? prob(vl, vr, lucky[i - k] + 1, lucky[i - k + 1])
                              : 0));
  }
  for (int i = 1; i < n; i++) {
    ans += prob(pl, pr, lucky[i - 1] + 1, lucky[i] - 1) *
           ((i + k < n ? prob(vl, vr, lucky[i + k - 1], lucky[i + k] - 1) : 0) +
            (i - k > 0 ? prob(vl, vr, lucky[i - k - 1] + 1, lucky[i - k]) : 0));
  }
  printf("%.9f\n", ans);
}
int main() { run(); }
