import java.util.Scanner;


public class collatz {

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

		Integer poleA[] = new Integer[25000];
		Integer poleB[] = new Integer[25000];
		String vysledky[] = new String[1000];
		
		while(true){
		
		for (int i = 0; i < poleB.length; i++) {
			
			if(poleB[i]!=null){
				poleB[i]=null;
				}else{
					break;
				}
		}
		
		for (int i = 0; i < poleA.length; i++) {
			if(poleA[i]!=null){
			poleA[i]=null;
			}else{
				break;
			}
		}
		

			
		String cisla = sc.nextLine();
		
		String poleCisel[] = cisla.split(" ");	
		
		long a = (long)Integer.valueOf(poleCisel[0]);
		long b = (long)Integer.valueOf(poleCisel[1]);
		
		
		
		if(a==0 && b==0){
			for (int i = 0; i < vysledky.length; i++) {
				if(vysledky[i]!=null){
					System.out.println(vysledky[i]);
				}
			}
			break;
		}
		
		long a2=a;
		long b2=b;
		
		poleA[0] = (int)a;
		poleB[0] = (int)b;
				
		int index = 1;
		
		while(a!=1){
			if(a%2==0){
				a=a/2;
				while(true){
					if(poleA[index]==null){
						poleA[index]=(int)a;
						break;
					}else{
						index++;
					}
				}
			}else{
				a=3*a+1;
				while(true){
					if(poleA[index]==null){
						poleA[index]=(int)a;
						break;
					}else{
						index++;
					}
				}
			}
		}
		
		index = 1;
		
		while(b!=1){
			if(b%2==0){
				b=b/2;
				while(true){
					if(poleB[index]==null){
						poleB[index]=(int)b;
						break;
					}else{
						index++;
					}
				}
			}else{
				b=3*b+1;
				while(true){
					if(poleB[index]==null){
						poleB[index]=(int)b;
						break;
					}else{
						index++;
					}
				}
			}
		}
		
		boolean vyskyt = false;
		
		int o = 0;
		
	for (int i = 0; i < poleB.length; i++) {
		if(vyskyt){break;}
		
		if(poleB[i]!=null){
			for (int j = 0; j < poleA.length; j++) {
				if(vyskyt){break;}
				
				if(poleA[j]!=null){
						
						String c = ""+poleB[i];
						String h = ""+poleA[j];
						
						if(c.equalsIgnoreCase(h)){
							while(true){
								if(vysledky[o]==null){
									vysledky[o]= a2 +" needs "+j+" steps, "+b2+" needs "+i+" steps, they meet at "+poleA[j];
									vyskyt=true;
									break;
								}else{
									o++;
								}
							}
						}
				}
			}
		}
	}
		
		
		
		
		}
		
	}
}
