using C=System.Console;class X{static void Main(){for(int n=0;(n+=C.Read())>0;)if(n>477)C.Write(487-n+"\n",n=0);}}