#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1);
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
inline double ABS(double a){return max(a,-a);}
struct Pt {
	double x, y;
	Pt() {}
	Pt(double x, double y) : x(x), y(y) {}
	Pt operator+(const Pt &a) const { return Pt(x + a.x, y + a.y); }
	Pt operator-(const Pt &a) const { return Pt(x - a.x, y - a.y); }
	Pt operator*(const Pt &a) const { return Pt(x * a.x - y * a.y, x * a.y + y * a.x); }
	Pt operator-() const { return Pt(-x, -y); }
	Pt operator*(const double &k) const { return Pt(x * k, y * k); }
	Pt operator/(const double &k) const { return Pt(x / k, y / k); }
	double ABS() const { return sqrt(x * x + y * y); }
	double abs2() const { return x * x + y * y; }
	double arg() const { return atan2(y, x); }
	double dot(const Pt &a) const { return x * a.x + y * a.y; }
	double det(const Pt &a) const { return x * a.y - y * a.x; }
};
double tri(const Pt &a, const Pt &b, const Pt &c) { return (b - a).det(c - a); }
int iSP(Pt a, Pt b, Pt c) {
	int s = sig((b - a).det(c - a));
	if (s) return s;
	if (sig((b - a).dot(c - a)) < 0) return -2; // c-a-b
	if (sig((a - b).dot(c - b)) < 0) return +2; // a-b-c
	return 0;
}
int iLL(Pt a, Pt b, Pt c, Pt d) {
	if (sig((b - a).det(d - c))) return 1; // intersect
	if (sig((b - a).det(c - a))) return 0; // parallel
	return -1; // correspond
}
bool iLS(Pt a, Pt b, Pt c, Pt d) {
//	printf("(%d)",sig(tri(a, b, c)) * sig(tri(a, b, d)));
	return (sig(tri(a, b, c)) * sig(tri(a, b, d)) <= 0);
}
bool iSS(Pt a, Pt b, Pt c, Pt d) {
	return (iSP(a, b, c) * iSP(a, b, d) <= 0 && iSP(c, d, a) * iSP(c, d, b) <= 0);
}
bool iSSstrict(Pt a, Pt b, Pt c, Pt d) {
	return (sig(tri(a, b, c)) * sig(tri(a, b, d)) < 0 && sig(tri(c, d, a)) * sig(tri(c, d, b)) < 0);
}
Pt pLL(Pt a, Pt b, Pt c, Pt d) {
	b = b - a; d = d - c; return a + b * (c - a).det(d) / b.det(d);
}
Pt hLP(Pt a,Pt b,Pt c){
	return pLL(a,b,c,c+(b-a)*Pt(0,1));
}

Pt s;
Pt p[10];
int perm[10];
Pt q[10];
Pt r[10];
pair<Pt,Pt>L[10];
int main(){
	int a;
	while(scanf("%d",&a),a){
		double X,Y;
		scanf("%lf%lf",&X,&Y);
		s=Pt(X,Y);
		for(int i=0;i<a;i++){
			scanf("%lf%lf",&X,&Y);
			p[i]=Pt(X,Y);
		}
		p[a]=p[0];
		int ret=0;
		for(int i=0;i<a;i++){
			perm[i]=i;
		}
		do{
			vector<Pt>v;
			for(int i=0;i<=a;i++){
				q[i]=p[i];
			}
			for(int i=0;i<a;i++){
				for(int j=0;j<=a;j++){
					r[j]=hLP(q[perm[i]],q[perm[i]+1],q[j]);
					r[j]=r[j]+r[j]-q[j];
				}
				for(int j=0;j<=a;j++)q[j]=r[j];
				L[i]=make_pair(q[perm[i]],q[perm[i]+1]);
				bool ok=true;
				for(int j=0;j<v.size();j++)if(iLL(s,q[perm[i]],s,v[j])!=1)ok=false;
				if(ok)v.push_back(q[perm[i]]);
				ok=true;
				for(int j=0;j<v.size();j++)if(iLL(s,q[perm[i]+1],s,v[j])!=1)ok=false;
				if(ok)v.push_back(q[perm[i]+1]);
			}
			//for(int i=0;i<a;i++)printf("(%f, %f)-(%f, %f) ",L[i].first.x,L[i].first.y,L[i].second.x,L[i].second.y);
			//printf("\n");
			int cnt=0;
			
			for(int i=0;i<v.size();i++){
				//printf("(%f, %f)",v[i].x,v[i].y);
				bool ok=true;
				double dist=0;
				for(int j=0;j<a;j++){
					if(!iLS(s,v[i],L[j].first,L[j].second)){
						//printf("(%d) ",j);
						ok=false;
						break;
					}
				//	Pt at=pLL(s,v[i],L[j].first,L[j].second);
				//	double t=(at-s).ABS();
				//	if(sig(t-dist)<0)ok=false;
				//	dist=t;
				}
				if(ok)cnt++;
			}
			//printf("\n");
			if(cnt>1){
				ret++;
			}
		}while(next_permutation(perm,perm+a));
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1080