import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.TreeSet;
import static java.lang.Math.pow;

public class differ_sm_double_simple {
	final double EPS = 1e-8;

	class Frac implements Comparable<Frac> {
		double d;

		public Frac(double a, double b) {
			d = a / b;
		}

		public Frac(double a) {
			this(a, 1);
		}

		@Override
		public int compareTo(Frac f) {
			if (Math.abs(d - f.d) < EPS) {
				return 0;
			}
			return Double.compare(d, f.d);
		}
	}

	void solve() throws IOException {
		double a = in.nextInt();
		double b = in.nextInt();
		TreeSet<Frac> ts = new TreeSet<Frac>();
		ts.add(new Frac(a + b));
		ts.add(new Frac(a - b));
		ts.add(new Frac(b - a));
		ts.add(new Frac(a * b));
		if (b != 0) {
			ts.add(new Frac(a, b));
		}
		if (a != 0) {
			ts.add(new Frac(b, a));
		}
		int ans = 0;
		if (a != 0 || b > 0) {
			ts.add(new Frac(pow(a, b)));
		}
		if (b != 0 || a > 0) {
			ts.add(new Frac(pow(b, a)));
		}
		out.println(ts.size() + ans);
	}

	Scanner in;
	PrintWriter out;
	final String filename = "differ";

	public void run() throws IOException {
		in = new Scanner(new FileReader(filename + ".in"));
		out = new PrintWriter(filename + ".out");
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new differ_sm_double_simple().run();
	}
}
