#include <bits/stdc++.h>
using namespace std;
long long pl, pr, vl, vr, K;
vector<long long> C;
double cut_p(long long L, long long R) {
  L = max(L, pl);
  R = min(R, pr);
  if (L > R) return 0;
  return (R - L + 1.0) / (pr - pl + 1.0);
}
double cut_v(long long L, long long R) {
  L = max(L, vl);
  R = min(R, vr);
  if (L > R) return 0;
  return (R - L + 1.0) / (vr - vl + 1.0);
}
int main() {
  cin >> pl >> pr >> vl >> vr >> K;
  for (int i = 1; i <= 9; ++i)
    for (int msk = 0; msk < (1 << i); ++msk) {
      long long T = 0;
      for (int j = 0; j < i; ++j) {
        T = 10 * T;
        if (msk & (1 << j))
          T += 7;
        else
          T += 4;
      }
      C.push_back(T);
    }
  C.push_back(-1);
  C.push_back(1000000002);
  sort(C.begin(), C.end());
  double ans = 0;
  for (int i = 1; i < C.size(); ++i) {
    int j = i + K - 1;
    if (j >= ((int)(C).size()) - 1) break;
    ans += cut_p(C[i - 1] + 1, C[i]) * cut_v(C[j], C[j + 1] - 1);
    ans += cut_v(C[i - 1] + 1, C[i]) * cut_p(C[j], C[j + 1] - 1);
  }
  if (K == 1) {
    double sub = 1.0 / (pr - pl + 1);
    sub /= (vr - vl + 1);
    for (int i = 0; i < C.size(); ++i)
      if (pl <= C[i] && C[i] <= pr && vl <= C[i] && C[i] <= vr) ans -= sub;
  }
  printf("%.12lf\n", ans);
  return 0;
}
