#include <bits/stdc++.h>
using namespace std;
double getnum(long int l, long int r, long int a, long int b) {
  l = max(l, a);
  r = min(r, b);
  if (l > r) return 0;
  return (double)(r - l + 1) / (b - a + 1);
}
int main() {
  int T;
  long int Pl, Pr, Vl, Vr, k, i, l1, r1, l2, r2, n;
  double ans;
  vector<long int> a;
  a.push_back(0);
  for (n = 1; n <= 9; ++n) {
    for (long int I = 0; I < (1 << n); ++I) {
      long int x = 0;
      for (int i = 0; i < n; ++i) {
        if (I & (1 << i))
          x = x * 10 + 4;
        else
          x = x * 10 + 7;
      }
      a.push_back(x);
    }
  }
  a.push_back(1000000001);
  sort(a.begin(), a.end());
  n = a.size();
  cin >> Pl >> Pr >> Vl >> Vr >> k;
  ans = 0;
  for (i = 1; i + k < n + 1; ++i) {
    l1 = a[i - 1] + 1;
    r1 = a[i];
    l2 = a[i + k - 1];
    r2 = a[i + k] - 1;
    ans += getnum(l1, r1, Pl, Pr) * getnum(l2, r2, Vl, Vr);
    ans += getnum(l2, r2, Pl, Pr) * getnum(l1, r1, Vl, Vr);
    if (r1 == l2) ans -= getnum(r1, l2, Pl, Pr) * getnum(r1, l2, Vl, Vr);
  }
  cout << setprecision(10) << fixed << ans << setprecision(0) << endl;
  return 0;
}
