import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
       public static void main(String args[])
       {
    	   Scanner cin=new Scanner(System.in);
    	   int a;
    	   BigInteger x,y;
    	   String str;
    	   while(cin.hasNextInt())
    	   {
    		   a=cin.nextInt();
    		   if(a==0)
    			   break;
    		   x=cin.nextBigInteger(a);
    		   y=cin.nextBigInteger(a);
    		   x=x.mod(y);
    		   str=x.toString(a);
    		   System.out.println(str);
    	   }
       }
}

  

posted on 2011-09-23 21:52  枫叶飘泪  阅读(246)  评论(0编辑  收藏  举报