#include <bits/stdc++.h>
using namespace std;
int plo, phi, vlo, vhi, k;
long long cnt = 0;
vector<int> lucky;
void make_lucky() {
  lucky.push_back(0);
  for (int i = 1; i <= 9; i++) {
    for (int j = 0; j < (1 << i); j++) {
      int c = j;
      int num = 0;
      int pow10 = 1;
      for (int k = 0; k < i; k++) {
        num += 4 * pow10;
        if (c % 2 == 1) {
          num += 3 * pow10;
        }
        c /= 2;
        pow10 *= 10;
      }
      lucky.push_back(num);
    }
  }
  lucky.push_back((long long)(1e9 + 1));
}
long long cover(int lo1, int hi1, int lo2, int hi2) {
  int lo = max(lo1, lo2);
  int hi = min(hi1, hi2);
  return max(0, hi - lo + 1);
}
int main() {
  cin >> plo >> phi >> vlo >> vhi >> k;
  make_lucky();
  for (int i = 1; i < lucky.size() - k; i++) {
    int lolo = lucky[i - 1] + 1;
    int lohi = lucky[i];
    int hilo = lucky[i + k - 1];
    int hihi = lucky[i + k] - 1;
    cnt += cover(lolo, lohi, plo, phi) * cover(hilo, hihi, vlo, vhi) +
           cover(lolo, lohi, vlo, vhi) * cover(hilo, hihi, plo, phi);
    if (k == 1 && plo <= lucky[i] && lucky[i] <= phi && vlo <= lucky[i] &&
        lucky[i] <= vhi)
      cnt--;
  }
  cout.precision(50);
  cout << 1.0 * cnt / (phi - plo + 1) / (vhi - vlo + 1);
}
