#include <bits/stdc++.h>
using namespace std;
const long maxint = 0x7fffffff;
int m = 0, border = 1000000000, l1, r1, l2, r2, k;
long long g[500000];
void calc(long long v) {
  if (v > border) return;
  g[m++] = v;
  calc(v * 10 + 4);
  calc(v * 10 + 7);
}
long long work(long long t1, long long t2, long long t3, long long t4) {
  long long ll, rr;
  ll = max(t1, t3);
  rr = min(t2, t4);
  if (ll > rr) return 0;
  return rr - ll + 1;
}
int main() {
  calc(0);
  sort(g, g + m);
  g[m] = border + 1;
  cin >> l1 >> r1 >> l2 >> r2 >> k;
  long long ans = 0, vv;
  vv = r1 - l1 + 1;
  vv *= r2 - l2 + 1;
  for (int i = 1; i + k - 1 < m; i++) {
    long long t1, t3, t2, t4;
    t1 = g[i - 1] + 1;
    t2 = g[i];
    t3 = g[i + k - 1];
    t4 = g[i + k] - 1;
    long long k1, k2;
    k1 = work(t1, t2, l1, r1) * work(t3, t4, l2, r2);
    k2 = work(t1, t2, l2, r2) * work(t3, t4, l1, r1);
    ans += k1 + k2;
    if (k == 1 && k1 && k2) ans--;
  }
  printf("%.12f\n", ans * 1. / vv);
}
