#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  int a=N%10;
  int b=(N/10)%10;
  int c=(N/100)%10;
  if((a%7)*(b%7)*(c%7) != 0){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
  
}
