#include <bits/stdc++.h>
using namespace std;
const long long N = 2e6 + 5, Mod = 1e9 + 7, MAXN = 1e8 + 1000, LG = 30,
                M = 1e6 + 5, P = 727, Sq = 100;
const long long inf = 3e18 + 10;
vector<long long> v;
long double pl, pr, vl, vr, k;
long double check1(long double f1, long double f2) {
  if (f2 < pl || f1 > pr) return 0;
  f1 = max(f1, pl);
  f2 = min(f2, pr);
  if (f1 > f2) return 0;
  long double tt = (f2 - f1 + 1), pp = pr - pl + 1;
  tt /= pp;
  return tt;
}
long double check2(long double f1, long double f2) {
  if (f2 < vl || f1 > vr) return 0;
  f1 = max(f1, vl);
  f2 = min(f2, vr);
  if (f1 > f2) return 0;
  long double tt = (f2 - f1 + 1), pp = vr - vl + 1;
  tt /= pp;
  return tt;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> pl >> pr >> vl >> vr >> k;
  for (long long i = 1; i <= 11; i++) {
    for (long long j = 0; j < (1 << i); j++) {
      long long ret = 0;
      for (long long x = 0; x < i; x++) {
        if (((1 << x) & j) > 0)
          ret *= 10, ret += 4;
        else
          ret *= 10, ret += 7;
      }
      v.push_back(ret);
    }
  }
  sort(v.begin(), v.end());
  long double res = 0;
  for (long long i = k - 1; i < (long long)v.size() - 1; i++) {
    long long l2 = v[i - k + 1], l1 = 0;
    if (i == k - 1)
      l1 = 1;
    else
      l1 = v[i - k] + 1;
    long long r2 = v[i + 1] - 1, r1 = v[i];
    res += check1(l1, l2) * check2(r1, r2);
    res += check2(l1, l2) * check1(r1, r2);
    if (l1 > r1) swap(l1, r1), swap(l2, r2);
    long long bad1 = max(l1, r1), bad2 = min(l2, r2);
    if (bad2 < bad1) continue;
    long double fg = vr - vl + 1;
    res -= check1(bad1, bad2) / fg;
  }
  cout << fixed << setprecision(12) << res << endl;
  return 0;
}
