import java.util.Arrays;
import java.util.Scanner;
public class Main {
//素数表
static boolean a[] = new boolean[1000001];
//记录连续最大数
static int b[] = new int[1000001];
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
//将数组元素都设为true
Arrays.fill(a, true);
int i,j,n=sc.nextInt();
//1 的情况定性
a[1] = false;
b[1] = 1;
//从2开始素数表
for(i=2;i<=n;i++) {
for(j=2;j<=Math.sqrt(i);j++) {
if(i%j==0) {
a[i] = false;
break;
}
}
//a[i]要么false 要么true
if(a[i]==false) {
if(a[i-1]==false) b[i] = b[i-1] + 1;
else b[i] = 1;
}
}
int mx = Integer.MIN_VALUE;
for(i=1;i<=n;i++) {
mx = Math.max(b[i],mx);
}
System.out.println(mx);
sc.close();
}
}
/**************************************************************
Problem: 1587
User: admin
Language: Java
Result: Accepted
Time:4320 ms
Memory:45456 kb
****************************************************************/