/*
TASK:dist
LANG:C++
*/

#include <stdio.h>
#include <math.h>

//using namespace std;

struct point
{
	long x;
	long y;
};

int n;
long x, y;
long min = 1500000;

point P[5000];
int used [5000] = {0};
int wrap [5000];

long dist (point p) //correct
{
	return (long) sqrt((p.x-x)*(p.x-x)+(p.y-y)*(p.y-y));
}

int sq (int i, int j)
{
	if (P[j].x - P[i].x > 0 && P[j].y - P[i].y > 0) return 1;
	if (P[j].x - P[i].x < 0 && P[j].y - P[i].y > 0) return 2;
	if (P[j].x - P[i].x < 0 && P[j].y - P[i].y < 0) return 3;
	if (P[j].x - P[i].x > 0 && P[j].y - P[i].y < 0) return 4;
}

double angl (int i, int j) 
{
	return atan2 ((double)(P[i].y-P[j].y),(double)P[i].x-P[j].x);
}

int isBetter (int cur, int i, int j) // correct
{
	if (sq (cur, i) < sq (cur, j)) return 1;
	if (sq (cur, j) < sq (cur, i)) return 0;
	if (angl (cur, i) < angl (cur, j)) return 1; 
	else return 0;
}

int main ()
{
	int i, m = 0;

	scanf ("%d %d %d ", &n, &x, &y);
	for (i = 0; i < n; i++)
	{
		scanf ("%d %d ", &P[i].x, &P[i].y);
		if (P[i].y < P[m].y) m = i;
	}

	int cur = m, nxt, f = 1;
	wrap [0] = m;
	do
	{
		nxt = (cur+1) % n;
		for (i = 0; i < n; i++)
			if (isBetter (cur, i, nxt) && i != cur)
				nxt = i;
		wrap[f++] = nxt;
		cur = nxt;
	} while (nxt != m);

	long d;
	for (i = 0; i < f; i++)
	{
		d = dist(P[wrap[i]]);
		if (d < min) min = d;
	}

	printf ("%d\n", min);
	return 0;
}
