#include <iostream>
#include <fstream>
using namespace std;
ifstream f ("numar.in");
int main()
{int n,a,s=0,gasit=0;
f>>n;
a=n+1;
while (gasit==0)
{s=0;
int copie=a;
while (copie>0){s=s+copie%10; copie=copie/10;}
if (s%7==0) gasit=1;
else a=a+1;
}
cout<<a;
}