#include <bits/stdc++.h>
using namespace std;
int pl, pr, vl, vr, k;
vector<int> lucky_numbers;
void generate(long long x) {
  if (x >= 1e9) return;
  lucky_numbers.push_back(x);
  generate(x * 10 + 4);
  generate(x * 10 + 7);
}
long double find(int a, int b, int c, int d) {
  if (c > b || d < a) return 0;
  c = max(a, c), d = min(b, d);
  long double ONE = 1;
  return ONE * (d - c + 1) / (b - a + 1);
}
int main() {
  cin >> pl >> pr >> vl >> vr >> k;
  generate(4), generate(7);
  sort(lucky_numbers.begin(), lucky_numbers.end());
  long double ans = 0;
  for (int i = 0; i < lucky_numbers.size(); i++) {
    if (i + k - 1 > lucky_numbers.size()) break;
    int prv = i ? lucky_numbers[i - 1] + 1 : 1;
    int nxt =
        i + k - 1 == lucky_numbers.size() - 1 ? 1e9 : lucky_numbers[i + k] - 1;
    ans += find(pl, pr, prv, lucky_numbers[i]) *
           find(vl, vr, lucky_numbers[i + k - 1], nxt);
    ans += find(vl, vr, prv, lucky_numbers[i]) *
           find(pl, pr, lucky_numbers[i + k - 1], nxt);
    if (k == 1)
      ans -= find(vl, vr, lucky_numbers[i], lucky_numbers[i]) *
             find(pl, pr, lucky_numbers[i], lucky_numbers[i]);
  }
  cout << setprecision(10) << fixed << ans;
  return 0;
}
