#include<bits/stdc++.h> using namespace std; int jie(int x){ int n=x; if(x==0) return 1; while(n>1){ n--; x=x*n; } return x; } int dfs(int x,int sum,int n){ if(sum==x) return 1; if(n==10) return -1; n++; return max(dfs(x,sum+jie(n),n),dfs(x,sum,n)); } int main(){ int x; while(cin>>x){ if(x<0) break; if(x==0) {cout<<"NO"<<endl;continue;} int sum=0;int flag=0; flag=dfs(x,sum,-1); if(flag==1) cout<<"YES"<<endl; else cout<<"NO"<<endl; } return 0; }