#include <stdio.h>
int main () {
long int cpf=0, cpf2=0;
int a=0, b=1, c=0, d=0, e=0, f=0, g=0, h=0, i=0, j=0;
// 123456789
scanf("%ld", &cpf);
a = (cpf % 10)*2;
b = (((cpf - a/2)/10)%10)*3;
c = (((cpf - b/3)/100)%10)*4;
d = (((cpf - c/4)/1000)%10)*5;
e = (((cpf - d/5)/10000)%10)*6;
f = (((cpf - e/6)/100000)%10)*7;
g = (((cpf - f/7)/1000000)%10)*8;
h = (((cpf - g/8)/10000000)%10)*9;
i = (((cpf - h/9)/100000000)%10)*10;
// printf ("%d %d %d %d\n", a , b, c, d);
int resto1 = (a+b+c+d+e+f+g+h+i)%11;
if (resto1==0 || resto1 ==1) {
printf ("%d", 0);
cpf2 = 10 * cpf;
} else {
printf("%d", 11- resto1);
cpf2 = 10 * cpf + 11 - resto1;
}
// printf ("\n%ld\n", cpf2);
a = (cpf2 % 10)*2;
b = (((cpf2 - a/2)/10)%10)*3;
c = (((cpf2 - b/3)/100)%10)*4;
d = (((cpf2 - c/4)/1000)%10)*5;
e = (((cpf2 - d/5)/10000)%10)*6;
f = (((cpf2 - e/6)/100000)%10)*7;
g = (((cpf2 - f/7)/1000000)%10)*8;
h = (((cpf2 - g/8)/10000000)%10)*9;
i = (((cpf2 - h/9)/100000000)%10)*10;
j = (((cpf2 - h/10)/1000000000)%10)*11;
resto1 = (a+b+c+d+e+f+g+h+i+j)%11;
if (resto1==0 || resto1 ==1) {
printf ("%d\n", 0);
// cpf2 = 10 * cpf;
} else {
printf("%d\n", 11- resto1);
// cpf2 = cpf = 10 * cpf + 11 - resto1;
}
return 0;
}