#include <bits/stdc++.h>
using namespace std;
long long p1, p2, v1, v2;
int K;
vector<long long> l;
double ret;
void rec(long long x) {
  if (x > 0) l.push_back(x);
  if ((long long)(x)*10 + 4 > 100000000005LL) return;
  rec(x * 10 + 4);
  rec(x * 10 + 7);
}
double countp(long long L, long long R) {
  if (L > R) return 0;
  long long A = max(p1, L), B = min(R, p2);
  if (A > B) return 0;
  return (B - A + 1) / (double)(p2 - p1 + 1);
}
double countv(long long L, long long R) {
  if (L > R) return 0;
  long long A = max(v1, L), B = min(R, v2);
  if (A > B) return 0;
  return (B - A + 1) / (double)(v2 - v1 + 1);
}
int main(void) {
  cin >> p1 >> p2 >> v1 >> v2 >> K;
  rec(0);
  sort(l.begin(), l.end());
  for (int i = 0; i + K - 1 < l.size(); ++i) {
    long long A = (i == 0) ? 1 : l[i - 1] + 1;
    long long B = l[i];
    long long C = l[i + K - 1];
    long long D = (i + K < l.size()) ? l[i + K] - 1 : max(p2, v2);
    ret += countp(A, B) * countv(C, D);
    ret += countp(C, D) * countv(A, B);
    if (B == C) ret -= countp(B, B) * countv(B, B);
  }
  printf("%.9lf\n", ret);
  return 0;
}
