#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
A cvt(B x) {
  stringstream ss;
  ss << x;
  A y;
  ss >> y;
  return y;
}
vector<int> lucky;
void gen(int len = 1, int x = 0) {
  if (x != 0) lucky.push_back(x);
  if (len <= 9) {
    gen(len + 1, x * 10 + 4);
    gen(len + 1, x * 10 + 7);
  }
}
int main() {
  gen();
  lucky.push_back(0);
  lucky.push_back(1000000000);
  sort(lucky.begin(), lucky.end());
  int a1, a2, b1, b2, k;
  scanf("%d %d %d %d %d", &a1, &a2, &b1, &b2, &k);
  if (b1 < a1) {
    swap(a1, b1);
    swap(a2, b2);
  }
  double r = 0;
  for (int i = 1; i + k < lucky.size(); i++) {
    int j = i + k - 1;
    double na, nb, nc;
    na = min(a2, lucky[i]) - max(lucky[i - 1], a1 - 1);
    nb = min(lucky[j + 1], b2 + 1) - max(b1, lucky[j]);
    if (na > 0 && nb > 0) r += na * nb;
    nb = min(b2, lucky[i]) - max(lucky[i - 1], b1 - 1);
    na = min(lucky[j + 1], a2 + 1) - max(a1, lucky[j]);
    if (na > 0 && nb > 0) r += na * nb;
  }
  if (k == 1) {
    int c1 = max(a1, b1), c2 = min(a2, b2);
    for (int i = 0; i < lucky.size(); i++)
      if (c1 <= lucky[i] && lucky[i] <= c2) r -= 1;
  }
  r /= (a2 - a1 + 1.0) * (b2 - b1 + 1.0);
  printf("%.11lf\n", r);
  return 0;
}
