// Arup Guha
// 10/15/2021
// Solution to 2021 UCF Locals Qualifying Round Problem: Heavy Numbers

import java.util.*;

public class heavy {

	public static void main(String[] args) {
	
		// Read input.
		Scanner stdin = new Scanner(System.in);
		int resa = weight(stdin.nextInt());
		int resb = weight(stdin.nextInt());
		
		// Ta da!
		if (resa > resb) System.out.println(1);
		else if (resa < resb) System.out.println(2);
		else System.out.println(0);
	}
	
	// Returns the weight of a number.
	public static int weight(int n) {
	
		// Just accumulate both, digit by digit.
		int numD = 0, sumD = 0;
		while (n > 0) {
			numD++;
			sumD += (n%10);
			n /= 10;
		}
		
		// Ta da!
		return numD*sumD;
	}
}