#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x < 0 ? -x : x;
}
const double pi = asin(1.0) * 2;
int n;
int m;
long long pl, pr, vl, vr;
int k;
vector<long long> h;
double prob(long long l, long long r, long long L, long long R) {
  L = max(l, L);
  R = min(R, r);
  if (L > R) return 0.0;
  return (R - L + 1) / (double)(r - l + 1);
}
int main() {
  cin >> pl >> pr >> vl >> vr >> k;
  h.push_back(0);
  int cur = 0;
  for (int i = cur; h[i] * 10 + 4 <= 1e10; i++) {
    h.push_back(h[i] * 10 + 4);
    h.push_back(h[i] * 10 + 7);
  }
  sort((h).begin(), (h).end());
  double ans = 0;
  for (int i = 1; i < (int)((h).size()); i++) {
    if (i + k >= (int)((h).size())) break;
    long long l1 = h[i - 1] + 1, r1 = h[i];
    long long l2 = h[i + k - 1], r2 = h[i + k] - 1;
    ans += prob(pl, pr, l1, r1) * prob(vl, vr, l2, r2);
    ans += prob(pl, pr, l2, r2) * prob(vl, vr, l1, r1);
    ans -= prob(pl, pr, max(l2, l1), min(r1, r2)) *
           prob(vl, vr, max(l2, l1), min(r1, r2));
  }
  printf("%.10lf\n", ans);
  return 0;
}
