#include <bits/stdc++.h>
using namespace std;
int pl, pr, vl, vr, k;
vector<int> lucky;
void gen_lucky(int len) {
  for (int i = 0; i < (1 << len); i++) {
    int num = 0;
    for (int j = 0; j < len; j++) {
      if (i & (1 << j))
        num = num * 10 + 4;
      else
        num = num * 10 + 7;
    }
    lucky.push_back(num);
  }
}
double prob(int l1, int r1, int l2, int r2) {
  return max(0, min(r1, r2) - max(l1, l2) + 1) / (r2 - l2 + 1.0);
}
int main() {
  scanf("%d%d%d%d%d", &pl, &pr, &vl, &vr, &k);
  for (int i = 1; i < 10; i++) gen_lucky(i);
  lucky.push_back(0);
  lucky.push_back(0x3f3f3f3f);
  sort(lucky.begin(), lucky.end());
  double ans = 0.0;
  for (int i = 0; i + k + 1 < lucky.size(); i++) {
    ans += prob(lucky[i] + 1, lucky[i + 1], pl, pr) *
           prob(lucky[i + k], lucky[i + k + 1] - 1, vl, vr);
    ans += prob(lucky[i] + 1, lucky[i + 1], vl, vr) *
           prob(lucky[i + k], lucky[i + k + 1] - 1, pl, pr);
    if (k == 1)
      ans -= prob(lucky[i + 1], lucky[i + 1], pl, pr) *
             prob(lucky[i + 1], lucky[i + 1], vl, vr);
  }
  printf("%.12lf\n", ans);
}
