#include <bits/stdc++.h>
using namespace std;
int main() {
  long N;
  int num[10];
  int ans;
  int ddd = 0, fff = 0, ggg = 0;
  int aAA = 0, AAA, BBB;
  scanf("%ld", &N);
  AAA = N;
  BBB = N;
  while (N) {
    N = N / 10;
    aAA++;
  }
  for (int k = 0; k < aAA; k++) {
    num[k] = AAA % 10;
    AAA /= 10;
  }
  for (int i = 0; i < aAA; i++) {
    if (num[i] >= 7) ddd++;
    if (num[i] >= 5) fff++;
    if (num[i] >= 3) ggg++;
  }
  ggg -= fff;
  fff -= ddd;
  if (ddd == 0 || fff == 0) goto Ans;
  ans = 3 * (ddd - 1) + 2 * (fff - 1);
Ans:;
  printf("%d\n", aAA);
  return 0;
}
