#include <bits/stdc++.h>
using namespace std;
int ini() {
  int a;
  scanf("%d", &a);
  return a;
}
long long inl() {
  long long a;
  scanf("%lld", &a);
  return a;
}
char inc() {
  char a;
  scanf("%c", &a);
  return a;
}
void readln() { scanf("\n"); }
const int oo = 2 * (int)1e9;
double giao(int a, int b, int x, int y) {
  return max(0, min(b, y) - max(a, x) + 1);
}
int main() {
  if (0) {
    freopen("aaa.inp", "r", stdin);
    freopen("aaa.out", "w", stdout);
  };
  int l1 = ini(), r1 = ini(), l2 = ini(), r2 = ini(), k = ini(), a[1111], m;
  a[0] = 0;
  a[1] = oo;
  m = 2;
  for (int i = 1; i < 10; i++) {
    for (int j = 0; j < (int)(1 << i); j++) {
      int c = 0;
      for (int k = 0; k < i; k++) {
        c *= 10;
        c += ((j >> k & 1) == 0) ? 4 : 7;
      }
      a[m++] = c;
    }
  }
  sort(a, a + m);
  double res = 0;
  for (int i = 1; i + k - 1 < m; i++) {
    double k1, k2;
    k1 = giao(a[i - 1] + 1, a[i], l1, r1) / (r1 - l1 + 1);
    k2 = giao(a[i + k - 1], a[i + k] - 1, l2, r2) / (r2 - l2 + 1);
    res += k1 * k2;
    if (k > 1) {
      k1 = giao(a[i - 1] + 1, a[i], l2, r2) / (r2 - l2 + 1);
      k2 = giao(a[i + k - 1], a[i + k] - 1, l1, r1) / (r1 - l1 + 1);
      res += k1 * k2;
    } else {
      k1 = giao(a[i - 1] + 1, a[i], l2, r2) / (r2 - l2 + 1);
      k2 = giao(a[i + k - 1] + 1, a[i + k] - 1, l1, r1) / (r1 - l1 + 1);
      res += k1 * k2;
      k1 = giao(a[i - 1] + 1, a[i] - 1, l2, r2) / (r2 - l2 + 1);
      k2 = giao(a[i], a[i], l1, r1) / (r1 - l1 + 1);
      res += k1 * k2;
    }
  }
  printf("%0.11f\n", res);
  return 0;
}
