#include <bits/stdc++.h>
using namespace std;
const int INF = 99999999;
long long pl, pr, vl, vr, k;
vector<long long> v;
void dfs(long long x, int digit) {
  if (digit >= 11) return;
  v.push_back(x);
  dfs(x * 10 + 4, digit + 1);
  dfs(x * 10 + 7, digit + 1);
}
inline long long intersection(long long l1, long long r1, long long l2,
                              long long r2) {
  long long l = max(l1, l2), r = min(r1, r2);
  return l > r ? 0 : r - l + 1;
}
int main() {
  v.clear();
  dfs(4, 1);
  dfs(7, 1);
  sort(v.begin(), v.end());
  while (cin >> pl >> pr >> vl >> vr >> k) {
    double cnt = 0, sum = (double)(pr - pl + 1) * (vr - vl + 1);
    for (int i = 0; i < v.size(); i++) {
      int j = i + k - 1;
      if (j >= v.size()) break;
      long long l1 = i == 0 ? -INF : v[i - 1] + 1;
      long long r1 = v[i];
      long long l2 = v[j];
      long long r2 = j >= v.size() - 1 ? INF : v[j + 1] - 1;
      cnt += intersection(l1, r1, pl, pr) * intersection(l2, r2, vl, vr);
      cnt += intersection(l1, r1, vl, vr) * intersection(l2, r2, pl, pr);
      if (k == 1 && intersection(r1, r1, pl, pr) &&
          intersection(l2, l2, vl, vr))
        cnt--;
    }
    printf("%.12lf\n", cnt / sum);
  }
  return 0;
}
