#include <bits/stdc++.h>
using namespace std;
vector<long long> lucky;
const long long inf = 1LL << 60;
int k;
long long pl, pr, vl, vr;
void dfs(long long x, int l) {
  lucky.push_back(x);
  if (l >= 11) return;
  dfs(10 * x + 4, l + 1);
  dfs(10 * x + 7, l + 1);
}
long long intersect(long long l1, long long r1, long long l2, long long r2) {
  long long ll = max(l1, l2), rr = min(r1, r2);
  if (ll > rr)
    return 0;
  else
    return (rr - ll + 1);
}
int main() {
  lucky.clear();
  dfs(4, 1);
  dfs(7, 1);
  sort(lucky.begin(), lucky.end());
  cin >> pl >> pr >> vl >> vr >> k;
  double a = 0, b = (double)(pr - pl + 1) * (vr - vl + 1);
  for (int i = 0; i < lucky.size(); i++) {
    int j = i + k - 1;
    if (j >= lucky.size()) break;
    long long l1 = (i == 0) ? -inf : lucky[i - 1] + 1;
    long long r1 = lucky[i];
    long long l2 = lucky[j];
    long long r2 = (j == lucky.size() - 1) ? inf : lucky[j + 1] - 1;
    a += (double)intersect(pl, pr, l1, r1) * intersect(vl, vr, l2, r2);
    a += (double)intersect(vl, vr, l1, r1) * intersect(pl, pr, l2, r2);
    if ((k == 1) && intersect(pl, pr, r1, r1) && intersect(vl, vr, l2, r2)) --a;
  }
  printf("%.18lf\n", a / b);
  return 0;
}
