#include <bits/stdc++.h>
using namespace std;
vector<long long> A;
void calc() {
  A.push_back(4);
  A.push_back(7);
  for (int i = 0; i < A.size(); ++i) {
    if (A[i] >= 1e8) continue;
    A.push_back(A[i] * 10 + 4);
    A.push_back(A[i] * 10 + 7);
  }
}
int main() {
  calc();
  long long pl, pr, vl, vr, k;
  long long ans = 0;
  cin >> pl >> pr >> vl >> vr >> k;
  for (int i = 0; i + k - 1 < A.size(); ++i) {
    long long MinPl, MinPr, MaxVl, MaxVr, MinVl, MinVr, MaxPl, MaxPr;
    if (A[i] < pl || (i - 1 >= 0 && A[i - 1] >= pr))
      MinPr = MinPl = 0;
    else {
      MinPl = max(i - 1 >= 0 ? A[i - 1] + 1 : 0ll, pl);
      MinPr = min(pr, A[i]);
    }
    if (A[i + k - 1] > vr || (i + k < A.size() && A[i + k] <= vl))
      MaxVl = MaxVr = 0;
    else {
      MaxVl = max(vl, A[i + k - 1]);
      MaxVr = min(i + k < A.size() ? A[i + k] - 1 : 100000000000ll, vr);
    }
    if (A[i] < vl || (i - 1 >= 0 && A[i - 1] >= vr))
      MinVl = MinVr = 0;
    else {
      MinVr = min(vr, A[i]);
      MinVl = max(i - 1 >= 0 ? A[i - 1] + 1 : 0ll, vl);
    }
    if (A[i + k - 1] > pr || (i + k < A.size() && A[i + k] <= pl))
      MaxPr = MaxPl = 0;
    else {
      MaxPl = max(pl, A[i + k - 1]);
      MaxPr = min(i + k < A.size() ? A[i + k] - 1 : 1000000000000ll, pr);
    }
    if (MinPr && MinPl && MaxVr && MaxVl)
      ans += (MinPr - MinPl + 1) * (MaxVr - MaxVl + 1);
    if (MinVr && MinVl && MaxPr && MaxPl)
      ans += (MinVr - MinVl + 1) * (MaxPr - MaxPl + 1);
    if ((MinPr && MinPl && MaxVr && MaxVl && MinVr && MinVl && MaxPr &&
         MaxPl) &&
        MinPr == MaxVl && MinVr == MaxPl)
      --ans;
  }
  long double answer =
      (long double)ans / ((long double)(pr - pl + 1) * (vr - vl + 1));
  cout << fixed << setprecision(12) << answer;
  return 0;
}
