#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
int main() {
  long long pl, pr, vl, vr, k;
  double ans = 0;
  cin >> pl >> pr >> vl >> vr >> k;
  for (int h = 1; h <= 9; h++) {
    for (int i = 0; i < (1 << h); i++) {
      int x = 0, y = 1;
      for (int j = 0; j < h; j++) {
        if (i & (1 << j)) {
          x += 4 * y;
        } else {
          x += 7 * y;
        }
        y *= 10;
      }
      v.push_back(x);
    }
  }
  v.push_back(0);
  sort(v.begin(), v.end());
  v.push_back(1e9 + 1);
  double pt = 0;
  for (int i = 0; i + k + 1 < v.size(); i++) {
    ans += max(0ll, (min(v[i + 1], pr) - max(v[i] + 1, pl)) + 1) *
           max(0ll, (min(v[i + k + 1] - 1, vr) - max(v[i + k], vl)) + 1);
    ans += max(0ll, (min(v[i + 1], vr) - max(v[i] + 1, vl)) + 1) *
           max(0ll, (min(v[i + k + 1] - 1, pr) - max(v[i + k], pl)) + 1);
    if (pt != ans && k == 1) {
      if (min(v[i + 1], pr) == max(v[i + k], vl) ||
          max(v[i] + 1, vl) == min(v[i + k + 1] - 1, pr)) {
        ans--;
      }
    }
    pt = ans;
  }
  double all = ((pr - pl) + 1) * ((vr - vl) + 1);
  cout << fixed << setprecision(12) << ans / all;
  return 0;
}
