#include <bits/stdc++.h>
using namespace std;
const int N = 20, Mod = 1e9 + 7;
int pl, pr, vl, vr, k;
long double p, q;
vector<int> v;
void count(int t) {
  int L, R;
  L = min(v[t], pr) - max(v[t - 1] + 1, pl);
  R = min(v[t + k] - 1, vr) - max(v[t + k - 1], vl);
  p += max(L + 1, 0) * 1ll * max(R + 1, 0);
  L = min(v[t], vr) - max(v[t - 1] + 1, vl);
  R = min(v[t + k] - 1, pr) - max(v[t + k - 1], pl);
  p += max(L + 1, 0) * 1ll * max(R + 1, 0);
  if (k == 1) {
    if (vl <= v[t] && v[t] <= vr && pl <= v[t] && v[t] <= pr) p--;
  }
}
void add(int length) {
  for (int i = 0; i < (1 << length); i++) {
    int num = 0;
    for (int j = 0; j < length; j++) {
      num *= 10;
      if (i & (1 << j))
        num += 4;
      else
        num += 7;
    }
    v.push_back(num);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> pl >> pr >> vl >> vr >> k;
  q = (pr - pl + 1) * 1ll * (vr - vl + 1);
  for (int i = 1; i <= 9; i++) add(i);
  v.push_back(0);
  v.push_back(Mod);
  v.push_back(Mod);
  sort(v.begin(), v.end());
  int n = v.size();
  for (int i = 1; i < n - k - 1; i++) {
    count(i);
  }
  cout << fixed << setprecision(10) << p / q;
  return 0;
}
