1. 
/**
* FWP: Ausgewaehlte Probleme aus dem ACM (SS10)
*
* Method: Math: Bases
* Problem: 550 - MultiplyingByRotation
* Accepted: 0.328
* @author Evgeni Pavlidis
*
*/
import java.util.*;
import java.io.*;

class Main {

public static void main(String...args)
{
Scanner scanner = new Scanner(System.in);

int base, firstFactor, secondFactor, carry, c, digit;

while(scanner.hasNextInt())
{
base = scanner.nextInt();
firstFactor = scanner.nextInt();
secondFactor = scanner.nextInt();

c = 0;
carry = 0;
digit = firstFactor;
do
{
digit = digit * secondFactor + carry;
carry = digit / base;
digit = digit % base;
//System.out.printf(" ===> %d %d carry = %d\n", digit, secondFactor, carry);
c++;

}while(carry > 0 || digit != firstFactor);

System.out.println(c);
}
}
}