#include<iostream>
#include<iomanip>
#include<math.h>
#include<bits/stdc++.h>
using namespace std;
int main(){
int i;
for(i = 1;i <= 999999;i++)
{
if(i % 2 == 1){
if(i % 3 == 2){
if(i % 5 == 4){
if(i % 6 == 5){
if(i % 7 == 0){
cout<<i<<endl;
break;
}
}
}
}
}
}
return 0;
}
/**************************************************************
Problem: 1265
User: admin
Language: C++
Result: Runtime Error
****************************************************************/