#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, a = 0, b = 0, c;
  string s;
  cin >> s;
  n = s.size();
  for (i = 0; i < n; i++) {
    if (s[i] == '4') {
      a++;
    }
    if (s[i] == '7') {
      b++;
    } else {
      a == 0;
      b == 0;
    }
  }
  c = a + b;
  if (c == 4 || c == 7)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
