#include <bits/stdc++.h>
using namespace std;
vector<long long> num;
long long n, pl, pr, vl, vr, k, ans;
void dfs(long long x) {
  if (x >= 1e9) return;
  num.push_back(x);
  dfs(x * 10 + 4);
  dfs(x * 10 + 7);
}
inline long long calc(long long l, long long r, long long x, long long y) {
  if (r < x || l > y) return 0;
  if (l > r || x > y) return 0;
  if (l >= x && l <= y) return min(r, y) - l + 1;
  if (r >= x && r <= y) return r - max(l, x) + 1;
  if (l < x && r > y) return y - x + 1;
}
int main() {
  dfs(0);
  n = num.size();
  num.push_back(1e16);
  sort(num.begin(), num.end());
  cin >> pl >> pr >> vl >> vr >> k;
  for (int i = 1; i + k - 1 <= n; i++) {
    if (num[i] > vr && num[i] > pr) break;
    int j = i + k - 1;
    ans += calc(num[i - 1] + 1, num[i], pl, pr) *
           calc(num[j], num[j + 1] - 1, vl, vr);
    ans += calc(num[j], num[j + 1] - 1, pl, pr) *
           calc(num[i - 1] + 1, num[i], vl, vr);
    if (k == 1) {
      if (calc(pl, pr, num[i], num[i]) && calc(vl, vr, num[i], num[i])) ans--;
    }
  }
  printf("%.12lf", ans * 1.0 / (vr - vl + 1) / (pr - pl + 1), 1.0);
}
