#include <bits/stdc++.h>
using namespace std;
vector<int> lucky;
void func0(int x) {
  if (x > 0) lucky.push_back(x);
  for (int i = 4; i < 8; i += 3)
    if (10LL * x + i < 1000000000) func0(10 * x + i);
}
int func(int l, int r, int a, int b) {
  if (l <= a && b <= r) return b - a + 1;
  if (l <= a) return max(0, r - a + 1);
  if (b <= r) return max(0, b - l + 1);
  return r - l + 1;
}
int main() {
  func0(0);
  lucky.push_back(0);
  lucky.push_back(2000000000);
  sort(lucky.begin(), lucky.end());
  int pl, pr, vl, vr, k;
  while (~scanf("%d%d%d%d%d", &pl, &pr, &vl, &vr, &k)) {
    double a = (pr - pl + 1.) * (vr - vl + 1.);
    double res = 0;
    for (int i = (1); i < (lucky.size() - k); ++i) {
      int p0 = func(pl, pr, lucky[i - 1] + 1, lucky[i]);
      int v0 = func(vl, vr, lucky[i - 1] + 1, lucky[i]);
      int p1 = func(pl, pr, lucky[i + k - 1], lucky[i + k] - 1);
      int v1 = func(vl, vr, lucky[i + k - 1], lucky[i + k] - 1);
      double a = (1. * p0 * v1) / (pr - pl + 1.);
      double b = (1. * p1 * v0) / (pr - pl + 1.);
      res += a + b;
      if (k == 1 && a > 0 && b > 0) res -= 1. / (pr - pl + 1.);
    }
    printf("%.10f\n", res / (vr - vl + 1.));
  }
  return 0;
}
