#include <bits/stdc++.h>
using namespace std;
long long inf = 100000000;
template <class T>
T bigmod(T b, T p, T m) {
  if (p == 1) return b;
  T res = bigmod(b, p / 2, m);
  res = (res * res) % m;
  if (p % 2 == 1) res = (res * b) % m;
  return res;
}
template <class T>
T gcd(T x, T y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
template <typename T>
T POW(T b, T p) {
  if (p == 1) return b;
  if (p % 2 == 0) {
    T s = POW(b, p / 2);
    return s * s;
  }
  return b * POW(b, p - 1);
}
long long a[3000900];
int main() {
  string n, s = "", a = "1", b = "41", c = "441";
  map<string, bool> mp;
  mp[a] = mp[b] = mp[c] = 1;
  cin >> n;
  for (long long i = n.size() - 1; i >= 0; i--) {
    s += n[i];
    if (mp[s] == 1) {
      s.clear();
    }
  }
  if (s.size() > 0)
    cout << "NO";
  else
    cout << "YES";
  return 0;
}
