#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
int p1, p2, v1, v2, k;
vector<int> lucky;
double prob(int sm, int bg, int st, int dr) {
  if (sm > dr || bg < st) return 0;
  if (bg > dr) bg = dr;
  if (sm < st) sm = st;
  return 1.0 * (bg - sm + 1) / (dr - st + 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> p1 >> p2 >> v1 >> v2 >> k;
  int idx = 0;
  lucky.push_back(0);
  for (int i = 1; i <= 9; ++i) {
    int sz = lucky.size();
    for (int j = idx; j < sz; ++j)
      lucky.push_back(lucky[j] * 10 + 4), lucky.push_back(lucky[j] * 10 + 7);
    idx = sz;
  }
  lucky.push_back(1000000001);
  double answer = 0;
  for (int i = 1; i + k < lucky.size(); ++i) {
    answer += prob(lucky[i - 1] + 1, lucky[i], p1, p2) *
              prob(lucky[i + k - 1], lucky[i + k] - 1, v1, v2);
    answer += prob(lucky[i - 1] + 1, lucky[i], v1, v2) *
              prob(lucky[i + k - 1], lucky[i + k] - 1, p1, p2);
    if (k == 1) {
      answer -=
          prob(lucky[i], lucky[i], p1, p2) * prob(lucky[i], lucky[i], v1, v2);
    }
  }
  printf("%.12lf", answer);
  return 0;
}
