#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=200+10;
const double inf=1e9, def=1e-9;
int n;
double w, h, ld[maxn], rd[maxn], dd[maxn][maxn], f[maxn][maxn];
bool rel[maxn][maxn], vis[maxn][maxn];
struct Point
{
double x, y;
Point(double _x=0, double _y=0)
{
x=_x, y=_y;
}
void sc()
{
scanf("%lf%lf", &x, &y);
}
double dis(Point t)
{
return sqrt((x-t.x)*(x-t.x)+(y-t.y)*(y-t.y));
}
double operator *(Point t)
{
return x*t.y-y*t.x;
}
Point operator -(Point t)
{
return Point(x-t.x, y-t.y);
}
}p[maxn];
struct Line
{
Point u, v;
double len;
Line(){}
Line(Point _u, Point _v)
{
u=_u, v=_v, len=_u.dis(_v);
}
bool par(Line t)
{
return fabs((v-u)*(t.v-t.u))<=def;
}
Point inter(Line t)
{
double s1=(t.v-u)*(t.u-u), s2=(t.u-v)*(t.v-v);
return Point((u.x*s2+v.x*s1)/(s1+s2), (u.y*s2+v.y*s1)/(s1+s2));
}
}line[maxn];
void Init()
{
for(int i=0; i<n*2; i++)
for(int j=0; j<n*2; j++) if(i!=j)
{
if(line[i].par(line[j]))
{
rel[i][j]=true;
dd[i][j]=inf;
}
else
{
Point o=line[i].inter(line[j]);
double l=o.dis(p[i]), r=o.dis(p[i+1]);
if(l<r)
{
rel[i][j]=true;
dd[i][j]=l;
}
else
{
rel[i][j]=false;
dd[i][j]=r;
}
}
}
Point g[5]={Point(0, 0), Point(w, 0), Point (w, h), Point(0, h), Point(0, 0)};
for(int i=0; i<2*n; i++)
{
ld[i]=rd[i]=inf;
for(int j=0; j<4; j++)
{
Line tp=Line(g[j], g[j+1]);
if(!line[i].par(tp))
{
Point o=line[i].inter(tp);
double l=o.dis(p[i]), r=o.dis(p[i+1]);
if(l<r) ld[i]=min(ld[i], l);
else rd[i]=min(rd[i], r);
}
}
}
return ;
}
double DP(int i, int j)
{
if(i>=j) return 0;
if(vis[i][j]) return f[i][j];
f[i][j]=inf;
vis[i][j]=true;
for(int k=i; k<j; k++)
{
double l=ld[k], r=rd[k];
if(rel[k][i-1]) l=min(l, dd[k][i-1]);
else r=min(r, dd[k][i-1]);
if(rel[k][j]) l=min(l, dd[k][j]);
else r=min(r, dd[k][j]);
f[i][j]=min(f[i][j], DP(i, k)+DP(k+1, j)+l+r+line[k].len);
}
return f[i][j];
}
int main()
{
while(scanf("%d%lf%lf", &n, &w, &h)!=EOF)
{
memset(vis, 0, sizeof vis);
memset(rel, 0, sizeof rel);
for(int i=0; i<n; i++) p[i].sc();
for(int i=n; i<=n*2; i++) p[i]=p[i-n];
for(int i=0; i<n*2; i++) line[i]=Line(p[i], p[i+1]);
double ans=inf;
Init();
for(int i=0; i<n; i++) ans=min(ans, DP(i+1, i+n)+ld[i]+rd[i]+line[i].len);
printf("%.6f\n", ans);
}
return 0;
}