#include <bits/stdc++.h>
using namespace std;
long long i, n, p1, p2, v1, v2, k, a, b, d, pmin, pmax, vmin, vmax, pl, pu, vl,
    vu;
vector<long long> l;
int main() {
  cin >> p1 >> p2 >> v1 >> v2 >> k;
  a = min(p1, v1);
  b = max(p2, v2);
  l.push_back(0);
  i = 0;
  while (l[l.size() - 1] <= b) {
    l.push_back(l[i] * 10 + 4);
    l.push_back(l[i] * 10 + 7);
    i++;
  }
  d = 0;
  for (i = 0; i < l.size() - k + 1; i++) {
    if (l[i] < a) continue;
    if (l[i + k - 1] > b) continue;
    pmin = max(p1, l[i - 1] + 1);
    pmax = min(p2, l[i]);
    vmin = max(v1, l[i + k - 1]);
    vmax = min(v2, l[i + k] - 1);
    if (pmax >= pmin && vmax >= vmin)
      d += (pmax - pmin + 1) * (vmax - vmin + 1);
    vmin = max(v1, l[i - 1] + 1);
    vmax = min(v2, l[i]);
    pmin = max(p1, l[i + k - 1]);
    pmax = min(p2, l[i + k] - 1);
    if (pmax >= pmin && vmax >= vmin)
      d += (pmax - pmin + 1) * (vmax - vmin + 1);
    if (k == 1 && l[i] <= vmax && l[i] >= vmin && l[i] >= pmin && l[i] <= pmax)
      d--;
  }
  double res = (double)d / (p2 - p1 + 1) / (v2 - v1 + 1);
  printf("%.9f", res);
}
