#include <iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

int main()
{int k,d,v,n,vk=v,x=0;
scanf("%d",&v);
while(vk>0){
while(vk>=10) {vk=vk/10;x=x+1;}
while(d<=vk&&d<=5){d=d+1;}
if(d=3||d=4)d=2;
vk=vk-d*pow(10,x);
}
printf("%d",d);
    return 0;
}