#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
vector<long long> vec;
long long pl, pr, vl, vr, k;
long double p(long long a, long long b, long long c, long long d) {
  long long l = max(a, c);
  long long r = min(b, d);
  long double x = max(0LL, r - l + 1);
  x /= (long double)(b - a + 1);
  return x;
}
long double f(long long l, long long r, long long a, long long b, long long c,
              long long d) {
  return (long double)p(a, b, (l == 0 ? 0 : vec[l - 1] + 1), vec[l]) *
         p(c, d, vec[r],
           (r == (long long)((vec).size()) - 1 ? 1e9 : vec[r + 1] - 1));
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  setprecision(100);
  for (long long x = 1; x <= 9; x++) {
    for (long long mask = 0; mask < (1 << x); mask++) {
      string s = "";
      for (long long j = 0; j < x; j++) {
        if (mask & (1 << j))
          s += '4';
        else
          s += '7';
      }
      vec.push_back(stoi(s));
    }
  }
  sort(vec.begin(), vec.end());
  cin >> pl >> pr >> vl >> vr >> k;
  long double ans = 0;
  for (long long i = 0; i + k - 1 < (long long)((vec).size()); i++) {
    ans += f(i, i + k - 1, pl, pr, vl, vr);
    ans += f(i, i + k - 1, vl, vr, pl, pr);
    if (k == 1 && (f(i, i + k - 1, pl, pr, vl, vr)) &&
        f(i, i + k - 1, vl, vr, pl, pr))
      ans -= (long double)(1) / ((vr - vl + 1) * (pr - pl + 1));
  }
  return cout << fixed << setprecision(20) << ans, 0;
}
