#include<bits/stdc++.h> using namespace std; int main(){ string a; long long b=0; cin>>a; for(int i=0;i<a.size();i++){ if(a[i]=='40'){ b++; }else if(a[i]=='41'){ b--; } } if(b==0){ cout<<"YES"; }else{ cout<<"NO"; } return 0; }