#include <bits/stdc++.h>
using namespace std;
int main() {
  int lucky[2000];
  int cnt = 0;
  lucky[cnt++] = 0;
  for (int d = 1; d <= 9; ++d)
    for (int b = 0; b < (1 << d); ++b) {
      int elem = 0;
      for (int i = d - 1; i >= 0; --i) {
        elem = elem * 10 + ((b & 1 << i) ? 7 : 4);
      }
      lucky[cnt++] = elem;
    }
  lucky[cnt++] = 1 << 30;
  int p[2], v[2], k;
  cin >> p[0] >> p[1] >> v[0] >> v[1] >> k;
  long long sum = 0LL;
  for (int a = 1, b = k; a < cnt - 1 && b < cnt - 1; ++a, ++b) {
    int x[2], y[2], s[2], t[2], d[2];
    int xx[2], yy[2];
    x[0] = max(p[0], lucky[a - 1] + 1);
    x[1] = min(p[1], lucky[a]);
    y[0] = max(v[0], lucky[b]);
    y[1] = min(v[1], lucky[b + 1] - 1);
    d[0] = x[1] - x[0] + 1;
    d[1] = y[1] - y[0] + 1;
    if (d[0] > 0 && d[1] > 0) sum += (long long)d[0] * d[1];
    s[0] = max(v[0], lucky[a - 1] + 1);
    s[1] = min(v[1], lucky[a]);
    t[0] = max(p[0], lucky[b]);
    t[1] = min(p[1], lucky[b + 1] - 1);
    d[0] = s[1] - s[0] + 1;
    d[1] = t[1] - t[0] + 1;
    if (d[0] > 0 && d[1] > 0) sum += (long long)d[0] * d[1];
    xx[0] = max(x[0], t[0]);
    xx[1] = min(x[1], t[1]);
    yy[0] = max(y[0], s[0]);
    yy[1] = min(y[1], s[1]);
    d[0] = xx[1] - xx[0] + 1;
    d[1] = yy[1] - yy[0] + 1;
    if (d[0] > 0 && d[1] > 0) sum -= (long long)d[0] * d[1];
  }
  double ans = sum / (1.0 * (p[1] - p[0] + 1) * (v[1] - v[0] + 1));
  printf("%.10lf\n", ans);
}
