#include <bits/stdc++.h>
using namespace std;
long long pl, pr, vl, vr, k;
long long all, ans = 0;
long long masK[2000];
int kl = -1;
void pereb(long long x) {
  if (x > 1000000000) return;
  masK[++kl] = x;
  pereb(x * 10 + 4);
  pereb(x * 10 + 7);
}
long long intersection(int x, int y, int x1, int y1) {
  if (y < x1 || y1 < x) return 0;
  return abs(min(y, y1) - max(x, x1)) + 1;
}
int main() {
  cin >> pl >> pr >> vl >> vr >> k;
  all = (pr - pl + 1) * (vr - vl + 1);
  pereb(0);
  masK[kl + 1] = 1000000005;
  sort(masK + 1, masK + kl + 1);
  int i = 1, j = i + k - 1;
  while (true) {
    long long c = intersection(masK[i - 1] + 1, masK[i], pl, pr) *
                  intersection(masK[j], masK[j + 1] - 1, vl, vr);
    long long c1 = intersection(masK[i - 1] + 1, masK[i], vl, vr) *
                   intersection(masK[j], masK[j + 1] - 1, pl, pr);
    ans += c + c1;
    if (k == 1 && c && c1) ans--;
    i++;
    j = i + k - 1;
    if (j > kl) break;
  }
  printf("%0.10f", double(1.0 * ans / all));
  return 0;
}
