for(i=1;;parseInt(b,i=i%10+1)==a&&print(i))i-1?0:[a,b]=readline().split(' ')