//模拟除法运算的过程
#include<stdio.h>
int main()
{
int i,n;
long num;
while(scanf("%d",&n) != EOF){
i = 1;
num = 1;
while(num % n != 0){
i++;
num = (num % n)*10 + 1;
}
printf("%d\n",i);
}
return 0;
}
//模拟除法运算的过程
#include<stdio.h>
int main()
{
int i,n;
long num;
while(scanf("%d",&n) != EOF){
i = 1;
num = 1;
while(num % n != 0){
i++;
num = (num % n)*10 + 1;
}
printf("%d\n",i);
}
return 0;
}