#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e11 + 7;
int pl, pr, vl, vr, k;
vector<long long> LN;
void init() {
  queue<long long> que;
  que.push(0);
  while (!que.empty()) {
    long long v = que.front();
    que.pop();
    if (v > 0) LN.push_back(v);
    v *= 10;
    if (v + 4 < INF) que.push(v + 4);
    if (v + 7 < INF) que.push(v + 7);
  }
  sort((LN).begin(), (LN).end());
}
double get(long long l1, long long r1, long long l2, long long r2) {
  if (r1 < l2 || r2 < l1) return 0;
  return min(r1, r2) - max(l1, l2) + 1;
}
double solve() {
  double ret = 0;
  for (int i = 0; i + k - 1 < ((int)(LN).size()); ++i) {
    long long l, r;
    double p1, p2;
    l = i ? LN[i - 1] + 1 : 1, r = LN[i];
    p1 = get(l, r, pl, pr) / (pr - pl + 1);
    l = LN[i + k - 1], r = i + 1 < ((int)(LN).size()) ? LN[i + k] - 1 : INF;
    p2 = get(l, r, vl, vr) / (vr - vl + 1);
    ret += p1 * p2;
    l = i ? LN[i - 1] + 1 : 1, r = LN[i];
    p2 = get(l, r, vl, vr) / (vr - vl + 1);
    l = LN[i + k - 1], r = i + 1 < ((int)(LN).size()) ? LN[i + k] - 1 : INF;
    p1 = get(l, r, pl, pr) / (pr - pl + 1);
    ret += max(0., p1 * p2 - 1.0 * (k == 1) / (pr - pl + 1) / (vr - vl + 1));
  }
  return ret;
}
int main() {
  init();
  scanf("%d%d%d%d%d", &pl, &pr, &vl, &vr, &k);
  printf("%.15f", solve());
  return 0;
}
