include Math
require 'matrix'
EPS = 1e-5
def atan(y, x)
	t = atan2(y, x)
	t < 0 ? t + 2 * PI : t
end

loop do
	n = gets.to_i
	break if n == 0
	count = 0
	sx, sy = gets.split.map(&:to_i)
	points = (1..n).map { gets.split.map(&:to_i) }
	orig_lines = (points + [points[0]]).each_cons(2).to_a.map(&:flatten)
	orig_lines.permutation(n) do |perm|
		lines = [perm.shift]
		until perm.empty?
			x1, y1, x2, y2 = lines[-1]
			o = Vector[x1, y1]
			u = Vector[x2 - x1, y2 - y1]
			t1 = atan(*u.to_a.reverse)
			perm.map! do |x3, y3, x4, y4|
				v = Vector[x3 - x1, y3 - y1]
				x = nil
				if v.r < EPS
					x = Vector[x3, y3]
				else
					t2 = atan(*v.to_a.reverse)
					dt = t2 - t1
					m = Matrix[
						[cos(-2 * dt), -sin(-2 * dt)],
						[sin(-2 * dt), cos(-2 * dt)],
					]
					x = (o + m * v)
				end
				y = nil
				if v.r < EPS
					y = Vector[x4, y4]
				else
					v = Vector[x4 - x1, y4 - y1]
					t2 = atan(*v.to_a.reverse)
					dt = t2 - t1
					m = Matrix[
						[cos(-2 * dt), -sin(-2 * dt)],
						[sin(-2 * dt), cos(-2 * dt)],
					]
					y = (o + m * v)
				end
				[*x.to_a, *y.to_a]
			end
			lines << perm.shift
		end

		ok = true
		ranges = lines.map do |x1, y1, x2, y2|
			t1 = atan(y1 - sy, x1 - sx)
			t2 = atan(y2 - sy, x2 - sx)
			t1, t2 = [t1, t2].sort
			if t2 - t1 < EPS
				ok = false
			end
			if t2 - t1 > PI
				[t2, t1]
			else
				[t1, t2]
			end
		end
		next unless ok

		angles = ([0] + ranges.flatten).uniq.sort + [2*PI]
		segments = angles.each_cons(2).to_a
		ranges.each do |t1, t2|
			if t1 > t2
				segments.select! do |t3, t4|
					(t1 <= t3 && t4 <= 2 * PI) || (0 <= t3 && t4 <= t2)
				end
			else
				segments.select! do |t3, t4|
					t1 <= t3 && t4 <= t2
				end
			end
		end

		count += 1 unless segments.empty?
	end
	p count
end