#include <bits/stdc++.h>
using namespace std;
typedef vector<vector<int>> graph;
ifstream in("buffcraft.in", ios::in);
ofstream out("buffcraft.out", ios::out);
int pl, pr, vl, vr, k;
vector<int> p;
void dfs(long long x) {
  if (x < 1000000000) {
    p.push_back(x);
    dfs(x * 10 + 4);
    dfs(x * 10 + 7);
  }
}
int main() {
  dfs(0);
  p.push_back(INT_MAX);
  sort(p.begin(), p.end());
  cin >> pl >> pr >> vl >> vr >> k;
  double cnt = 0;
  double all = ((vr - vl) + 1.0) * ((pr - pl) + 1.0);
  for (int i = 1; i < p.size() - k; i++) {
    int lm = p[i - 1] + 1, l = p[i], r = p[i + k - 1], rp = p[i + k] - 1;
    if (pl <= l && pr >= lm && vl <= rp && vr >= r)
      cnt +=
          (min(pr, l) - max(pl, lm) + 1.0) * (min(vr, rp) - max(vl, r) + 1.0);
    if (vl <= l && vr >= lm && pl <= rp && pr >= r) {
      cnt +=
          (min(vr, l) - max(vl, lm) + 1.0) * (min(pr, rp) - max(pl, r) + 1.0);
      if (k == 1) cnt -= 1.0;
    }
  }
  cout << setprecision(10) << cnt / all;
}
