#include <bits/stdc++.h>
using namespace std;
const bool local = false;
const int MAXK = 5000;
int a[MAXK];
inline long long intersect(int a, int b, int c, int d) {
  int ans = min(b, d) - max(a, c) + 1;
  return (ans > 0 ? ans : 0);
}
int main() {
  if (local) {
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
  }
  int n;
  int cnt = 0;
  a[cnt++] = 0;
  for (int i = 0; i < 10; i++) {
    if (!i) continue;
    for (int j = 0; j < (1 << i); j++) {
      for (int k = 0; k < i; k++) {
        if (j & (1 << (i - 1 - k)))
          a[cnt] = a[cnt] * 10 + 7;
        else
          a[cnt] = a[cnt] * 10 + 4;
      }
      cnt++;
    }
  }
  a[cnt++] = 1e9 + 1;
  int p1, p2, v1, v2, k;
  scanf("%d %d %d %d %d", &p1, &p2, &v1, &v2, &k);
  long long good = 0;
  for (int i = 0; i < cnt - k - 1; i++) {
    good += intersect(a[i] + 1, a[i + 1], p1, p2) *
            intersect(a[i + k], a[i + k + 1] - 1, v1, v2);
    good += intersect(a[i] + 1, a[i + 1], v1, v2) *
            intersect(a[i + k], a[i + k + 1] - 1, p1, p2);
  }
  if (k == 1) {
    for (int i = 0; i < cnt - 1; i++) {
      if (!i) continue;
      if ((a[i] >= max(p1, v1)) && (a[i] <= min(p2, v2))) good--;
    }
  }
  long double ans = good;
  ans /= (p2 - p1 + 1);
  ans /= (v2 - v1 + 1);
  printf("%.9f", (double)ans);
}
