#include <bits/stdc++.h>
const int BUFFSIZE = 10240;
char BUFF[BUFFSIZE + 1], *p = BUFF;
int CHAR, SIGN, BYTES = 0;
using namespace std;
vector<long long> V;
void dfs(long long N) {
  if (N > 5000000000LL) return;
  V.push_back(N);
  dfs(N * 10 + 4);
  dfs(N * 10 + 7);
}
int main() {
  dfs(0);
  sort(V.begin(), V.end());
  long long pl, pr, vl, vr, k;
  cin >> pl >> pr >> vl >> vr >> k;
  double den = (pr - pl + 1) * (vr - vl + 1);
  double num = 0;
  for (int i = 1; i + k - 1 < V.size(); i++) {
    long long x = V[i];
    long long y = V[i + k - 1];
    long long lftp = V[i - 1] + 1;
    long long rgtp = x;
    long long lftv = y;
    long long rgtv = V[i + k] - 1;
    lftp = max(lftp, pl);
    rgtp = min(rgtp, pr);
    lftv = max(lftv, vl);
    rgtv = min(rgtv, vr);
    if (lftp <= rgtp && lftv <= rgtv) {
      double prob = (rgtp - lftp + 1.0) * (rgtv - lftv + 1.0);
      num += prob;
    }
    lftv = V[i - 1] + 1;
    rgtv = x;
    lftp = y;
    rgtp = V[i + k] - 1;
    lftp = max(lftp, pl);
    rgtp = min(rgtp, pr);
    lftv = max(lftv, vl);
    rgtv = min(rgtv, vr);
    if (lftp <= rgtp && lftv <= rgtv) {
      double prob = (rgtp - lftp + 1.0) * (rgtv - lftv + 1.0);
      num += prob;
    }
  }
  if (k == 1) {
    for (int i = 1; i < V.size(); i++)
      if (V[i] >= pl && V[i] <= pr && V[i] >= vl && V[i] <= vr) num -= 1;
  }
  double res = 1.0 * num / den;
  printf("%.20lf\n", res);
  return 0;
}
