#include <bits/stdc++.h>
using namespace std;
int l[2000], ln;
void go(int a) {
  l[ln++] = a;
  if (a > 1e8) return;
  go(a * 10 + 4);
  go(a * 10 + 7);
}
void predo() {
  ln = 0;
  go(0);
  l[ln++] = 1000000000;
  sort(l, l + ln);
}
long long int len(int a, int b, int c, int d) {
  int k = min(b, d) - max(a, c) + 1;
  return k >= 0 ? k : 0;
}
int main() {
  predo();
  int l1, r1, l2, r2, k;
  scanf("%d%d%d%d%d", &l1, &r1, &l2, &r2, &k);
  long long int ans = 0;
  for (int i = 1; i + k < ln; i++) {
    ans += len(l[i - 1] + 1, l[i], l1, r1) *
           len(l[i + k - 1], l[i + k] - 1, l2, r2);
    ans += len(l[i - 1] + 1, l[i], l2, r2) *
           len(l[i + k - 1], l[i + k] - 1, l1, r1);
    if (k == 1 && len(l[i], l[i], l1, r1) == 1 && len(l[i], l[i], l2, r2) == 1)
      ans--;
  }
  printf("%.11lf\n", (double)ans / (r1 - l1 + 1) / (r2 - l2 + 1));
  return 0;
}
