#include <bits/stdc++.h>
using namespace std;
vector<int> luck;
void gera(long long at) {
  if (at > 1000000000ll) return;
  if (at) luck.push_back((int)at);
  gera(10ll * at + 4);
  gera(10ll * at + 7);
}
double prob(int a, int b, int ini, int fim) {
  double tam = b - a + 1;
  double inter = min(b, fim) - max(a, ini) + 1;
  if (inter < 0) inter = 0;
  return inter / tam;
}
int main() {
  luck.clear();
  gera(0);
  luck.push_back(0);
  luck.push_back(1000000001);
  sort(luck.begin(), luck.end());
  int a, b, c, d, k;
  cin >> a >> b >> c >> d >> k;
  double ans = 0;
  int ini = 1, fim = k;
  while (fim + 1 < (int)(luck).size()) {
    ans += prob(a, b, luck[ini - 1] + 1, luck[ini]) *
           prob(c, d, luck[fim], luck[fim + 1] - 1);
    ans += prob(c, d, luck[ini - 1] + 1, luck[ini]) *
           prob(a, b, luck[fim], luck[fim + 1] - 1);
    if (k == 1)
      ans -=
          prob(c, d, luck[ini], luck[ini]) * prob(a, b, luck[fim], luck[fim]);
    fim++;
    ini++;
  }
  cout.precision(15);
  cout << fixed << ans << endl;
  return 0;
}
