#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<long long> lucky = {4, 7};
  map<long long, long long> next, prev;
  next[4] = 7;
  prev[4] = 0;
  for (int i = 0; i < 1025; ++i) {
    next[lucky[i]] = lucky[i + 1] - 1;
    if (i > 0) {
      prev[lucky[i]] = lucky[i - 1] + 1;
    }
    lucky.push_back(lucky[i] * 10 + 4);
    lucky.push_back(lucky[i] * 10 + 7);
  }
  map<pair<long long, long long>, long long> count;
  for (int i = 0; i < lucky.size(); ++i) {
    for (int j = i; j < lucky.size(); ++j) {
      count[{lucky[i], lucky[j]}] = j - i + 1;
    }
  }
  long long l1, r1, l2, r2, k;
  cin >> l1 >> r1 >> l2 >> r2 >> k;
  long long answer = 0;
  for (auto i : count) {
    if (i.second == k) {
      answer +=
          max(max((min(r1, i.first.first) - max(l1, prev[i.first.first]) + 1),
                  (long long)0) *
                  max(((min(r2, next[i.first.second]) -
                        max(l2, i.first.second) + 1)),
                      (long long)0),
              (long long)0);
      answer +=
          max(max((min(r2, i.first.first) - max(l2, prev[i.first.first]) + 1),
                  (long long)0) *
                  max(((min(r1, next[i.first.second]) -
                        max(l1, i.first.second) + 1)),
                      (long long)0),
              (long long)0);
      if (k == 1 and (i.first.first >= l1 and i.first.first <= r1 and
                      i.first.first >= l2 and i.first.first <= r2)) {
        answer--;
      }
    }
  }
  cout << fixed << setprecision(10)
       << (long double)answer / ((r2 - l2 + 1) * (r1 - l1 + 1));
  return 0;
}
