#include <bits/stdc++.h>
using namespace std;
vector<long long> lucky;
int size;
void dfs(int i, long long num) {
  if (num > 1000000000) return;
  lucky.push_back(num);
  dfs(i + 1, num * 10 + 4);
  dfs(i + 1, num * 10 + 7);
}
long long func(long long x1, long long x2, long long y1, long long y2, int k) {
  int i, j;
  long long ans = 0;
  for ((i) = 0; (i) < (int)(size - k + 1); (i)++) {
    long long xlow = x1, xhigh = x2, ylow = y1, yhigh = y2;
    j = i + k - 1;
    if (i != 0) xlow = max(x1, lucky[i - 1] + 1);
    xhigh = min(x2, lucky[i]);
    ylow = max(y1, lucky[j]);
    if (j != (size - 1)) yhigh = min(lucky[j + 1] - 1, y2);
    if (xhigh >= xlow && yhigh >= ylow)
      ans += (xhigh - xlow + 1) * (yhigh - ylow + 1);
  }
  return ans;
}
int main() {
  int i, n, k;
  long long x1, x2, y1, y2;
  long long ans, total;
  dfs(0, 4);
  dfs(0, 7);
  sort(lucky.begin(), lucky.end());
  size = lucky.size();
  cin >> x1 >> x2 >> y1 >> y2 >> k;
  total = (x2 - x1 + 1) * (y2 - y1 + 1);
  ans = func(x1, x2, y1, y2, k) + func(y1, y2, x1, x2, k);
  if (k == 1)
    for ((i) = 0; (i) < (int)(size); (i)++)
      if (x1 <= lucky[i] && x2 >= lucky[i] && y1 <= lucky[i] && y2 >= lucky[i])
        ans--;
  cout << fixed << setprecision(12) << (double)ans / (double)total << endl;
  return 0;
}
