#include <bits/stdc++.h>
using namespace std;
long long pl, pr, vl, vr, k, a[10020], t, x, y, z = 0;
int c = 0;
void dfs(long long x) {
  if (x > 1e10) return;
  a[c++] = x;
  dfs(x * 10 + 4);
  dfs(x * 10 + 7);
}
long long fun(long long pl, long long pr, long long vl, long long vr) {
  return max(min(pr, vr) - max(pl, vl) + 1, 0LL);
}
int main() {
  cin >> pl >> pr >> vl >> vr >> k;
  t = (pr - pl + 1) * (vr - vl + 1);
  dfs(0);
  sort(a, a + c);
  for (int i = 1, j; i + k < c; i++) {
    j = i + k;
    x = fun(a[i - 1] + 1, a[i], pl, pr);
    y = fun(a[j - 1], a[j] - 1, vl, vr);
    z += x * y;
    x = fun(a[i - 1] + 1, a[i], vl, vr);
    y = fun(a[j - 1], a[j] - 1, pl, pr);
    z += x * y;
    if (k == 1 && pl <= a[i] && a[i] <= pr && vl <= a[i] && a[i] <= vr) z--;
  }
  printf("%.15lf\n", 1.0 * z / t);
  return 0;
}
