import java.util.Scanner;

class Assignment6C
{
	public static void main (String[] args)
	{
         int number;
         int originalNumber;
         int oneCounter=0;
         int twoCounter=0;
         int choice;
         int digit;
         Scanner input = new Scanner (System.in);
         System.out.println("This program will determine if a number has 1 more 1 than 2's ");
         do
			{
				 System.out.println("Please type in a number ");
		         number=input.nextInt();
		         originalNumber=number;
				do  //get the digits
				{
					digit=number%10;
					number=number/10;
					if (digit==1)
						oneCounter=oneCounter+1;
					else if (digit==2)
							twoCounter=twoCounter+1;
					
				}while(number >0);
				if (oneCounter-twoCounter==1)	
					 System.out.printf("The number %d has one more 1 than 2\n", originalNumber);
				else	
						 System.out.printf("The number %d does not work\n", originalNumber);
		       	 
				System.out.println("Would you like to continue ? (0-no/1-yes) ");
		         choice = input.nextInt();
			}while (choice != 0);
		          
	  
	}
} 