#include <bits/stdc++.h>
std::vector<long long> lucky_nums;
int num = 0;
void generate_lucky() {
  lucky_nums.push_back(0);
  for (int i = 1; i < 1024; ++i) {
    long long current = i;
    long long number = 0;
    long long c_pow = 1;
    while (current) {
      long long last_d = current & 1;
      number += (last_d == 0 ? 4 : 7) * c_pow;
      c_pow *= 10;
      current >>= 1;
    }
    if (number < 0) break;
    long long symetric_num = (number - 7 * c_pow / 10) + 4 * c_pow / 10;
    lucky_nums.push_back(symetric_num);
    lucky_nums.push_back(number);
  }
  std::sort(lucky_nums.begin(), lucky_nums.end());
}
long long contain(long long x1, long long y1, long long x2, long long y2) {
  long long l = std::max(x1, x2);
  long long r = std::min(y1, y2);
  return r - l + 1 > 0 ? r - l + 1 : 0;
}
const int maxLuckyCount = 1022;
int main() {
  long long Pl, Pr, Vl, Vr;
  int k;
  std::cin >> Pl >> Pr >> Vl >> Vr >> k;
  long long ans = 0;
  generate_lucky();
  for (int i = 1; i <= maxLuckyCount - k + 1; i++) {
    int j = i + k - 1;
    ans += contain(lucky_nums[i - 1] + 1, lucky_nums[i], Pl, Pr) *
           contain(lucky_nums[j], lucky_nums[j + 1] - 1, Vl, Vr);
    if (lucky_nums[i] > Pr) break;
  }
  for (int i = 1; i <= maxLuckyCount - k + 1; i++) {
    int j = i + k - 1;
    ans += contain(lucky_nums[i - 1] + 1, lucky_nums[i], Vl, Vr) *
           contain(lucky_nums[j], lucky_nums[j + 1] - 1, Pl, Pr);
    if (lucky_nums[i] > Vr) break;
  }
  if (k == 1) {
    for (int i = 1; i <= maxLuckyCount; i++) {
      if (contain(lucky_nums[i], lucky_nums[i], Pl, Pr) &&
          contain(lucky_nums[i], lucky_nums[i], Vl, Vr))
        ans--;
    }
  }
  std::cout.precision(20);
  std::cout << static_cast<double>(ans) / ((Vr - Vl + 1) * (Pr - Pl + 1));
}
