#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
void bfs() {
  queue<long long> q;
  v.push_back(4);
  v.push_back(7);
  q.push(4);
  q.push(7);
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    if (u >= (1LL << 30)) continue;
    v.push_back(u * 10 + 4);
    v.push_back(u * 10 + 7);
    q.push(u * 10 + 4);
    q.push(u * 10 + 7);
  }
}
double dp[2055];
int main() {
  bfs();
  sort(v.begin(), v.end());
  memset(dp, 0, sizeof(dp));
  long long p1, p2, v1, v2, n;
  cin >> p1 >> p2 >> v1 >> v2 >> n;
  for (int i = v.size(); i >= n; i--) {
    for (int j = v.size() - 1; j + 1 >= i; j--) {
      long long rt = v[j];
      long long lt = v[j + 1 - i];
      double x = -1, xx = -1, y = -1, yy = -1;
      if (rt <= p2 && lt >= v1) {
        dp[i] += 1.0 * (p2 - max(p1, rt) + 1) / (p2 - p1 + 1) *
                 (min(lt, v2) - v1 + 1) / (v2 - v1 + 1);
        x = max(p1, rt);
        y = min(lt, v2);
      }
      if (rt <= v2 && lt >= p1) {
        dp[i] += 1.0 * (v2 - max(v1, rt) + 1) / (v2 - v1 + 1) *
                 (min(lt, p2) - p1 + 1) / (p2 - p1 + 1);
        xx = min(lt, p2);
        yy = max(v1, rt);
      }
      if (x != -1 && xx != -1 && y != -1 && yy != -1 && x <= xx && y >= yy)
        dp[i] -=
            (xx - x + 1) * 1.0 / (p2 - p1 + 1) * (y - yy + 1) / (v2 - v1 + 1);
    }
  }
  for (int i = v.size(); i >= n; i--)
    for (int j = i + 1; j <= v.size(); j++) dp[i] -= (j - i + 1) * dp[j];
  printf("%.20lf\n", dp[n]);
  return 0;
}
