#include <bits/stdc++.h>
using namespace std;
const int oo = (int)1e9, MAXN = (int)1e6, risk = (int)1e6;
const double eps = 1e-9;
vector<int> lucky;
void find(long long l) {
  if (l >= 1000000000) return;
  lucky.push_back(l);
  find(l * 10 + 4);
  find(l * 10 + 7);
}
vector<pair<pair<int, int>, pair<int, int> > > quad;
void findquad(int k) {
  int c = 0, lo = 0;
  for (int i = (k - 1); i <= (lucky.size() - 1); i++) {
    pair<int, int> l = make_pair(lo + 1, lucky[i - k + 1]);
    pair<int, int> r = make_pair(
        lucky[i], (i == lucky.size() - 1) ? 1000000000 : lucky[i + 1] - 1);
    quad.push_back(make_pair(l, r));
    lo = lucky[i - k + 1];
  }
}
long long intersect(long long x1, long long x2, long long y1, long long y2) {
  if (x1 > y1) swap(x1, y1), swap(x2, y2);
  if (x2 < y1) return 0;
  if (x2 > y2) return y2 - y1 + 1;
  return x2 - y1 + 1;
}
char w[] = {'a', 'b', 'c', 'd'};
int main() {
  long long a, a1, a2, b, b1, b2, k, l, r;
  find(4);
  find(7);
  sort((lucky).begin(), (lucky).end());
  cin >> a1 >> a2 >> b1 >> b2 >> k;
  a = a2 - a1 + 1, b = b2 - b1 + 1;
  findquad(k);
  double ans = 0;
  for (int i = 0; i < (quad.size()); i++) {
    long long l1 = quad[i].first.first;
    long long l2 = quad[i].first.second;
    long long r1 = quad[i].second.first;
    long long r2 = quad[i].second.second;
    l = intersect(l1, l2, a1, a2);
    r = intersect(r1, r2, b1, b2);
    ans += double(l * r) / double(a * b);
    l = intersect(l1, l2, b1, b2);
    r = intersect(r1, r2, a1, a2);
    ans += double(l * r) / double(a * b);
  }
  if (k == 1) {
    for (int i = 0; i < (lucky.size()); i++)
      if (a1 <= lucky[i] && a2 >= lucky[i] && b1 <= lucky[i] && b2 >= lucky[i])
        ans -= 1.0 / double(a * b);
  }
  printf("%.10lf\n", ans);
  return 0;
}
