Problem: You have got a new job, and it's very interesting, you are a ship captain. Your first task is to move your ship from one point to another point, and for sure you want to move it at the minimum cost.

And it's well known that the shortest distance between any 2 points is the length of the line segment between these 2 points. But unfortunately there is an island in the sea, so sometimes you won't be able to move your ship in the line segment between the 2 points.

You can only move to safe points. A point is called safe if it's on the line segment between the start and end points, or if it's on the island's edge.

But you are too lucky, you have got some clever and strong workers and they can help you in your trip, they can help you move the ship in the sea and they will take 1 Egyptian pound for each moving unit in the sea, and they can carry the ship (yes, they are very strong) and walk on the island and they will take 2 Egyptian pounds for each moving unit in the island. The money which you will give to them will be divided between all workers, so the number of workers does not matter here.

You can move your ship on the island edge, and it will be considered moving in the sea.

Now you have a sea map, and you have to decide what is the minimum cost for your trip.

Your starting point is (xStart, yStart), and the end point is (xEnd, yEnd), both points will be different.

The island will be a convex polygon and there will be no more than 2 polygon points on the same line, also the starting and the end points won't be inside or on the boundary of the island. The points for the polygon will be given in the anti-clockwise order.

Input

The first line contains 4 integers, xStart, yStart, xEnd and yEnd ( - 100 ≤ xStart, yStart, xEnd, yEnd ≤ 100). The second line contains an integer n, which is the number of points in the polygon (3 ≤ n ≤ 30), followed by a line containing n pairs of integers x and y, which are the coordinates of the points ( - 100 ≤ x, y ≤ 100), the polygon points will be distinct.

Output

Print one line which contains the minimum possible cost. The absolute or relative error in the answer should not exceed 10 - 6.

Examples

Input

1 7 6 7
4
4 2 4 12 3 12 3 2


Output

6.000000000


Input

-1 0 2 0
4
0 0 1 0 1 1 0 1


Output

3.000000000

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
double INF = 1e100;
double EPS = 1e-8;
struct PT {
  double x, y;
  PT() {}
  PT(double x, double y) : x(x), y(y) {}
  PT(const PT &p) : x(p.x), y(p.y) {}
  PT operator+(const PT &p) const { return PT(x + p.x, y + p.y); }
  PT operator-(const PT &p) const { return PT(x - p.x, y - p.y); }
  PT operator*(double c) const { return PT(x * c, y * c); }
  PT operator/(double c) const { return PT(x / c, y / c); }
};
double dot(PT p, PT q) { return p.x * q.x + p.y * q.y; }
double dist2(PT p, PT q) { return dot(p - q, p - q); }
double cross(PT p, PT q) { return p.x * q.y - p.y * q.x; }
ostream &operator<<(ostream &os, const PT &p) {
  os << "(" << p.x << "," << p.y << ")";
}
PT RotateCCW90(PT p) { return PT(-p.y, p.x); }
PT RotateCW90(PT p) { return PT(p.y, -p.x); }
PT RotateCCW(PT p, double t) {
  return PT(p.x * cos(t) - p.y * sin(t), p.x * sin(t) + p.y * cos(t));
}
PT ProjectPointLine(PT a, PT b, PT c) {
  return a + (b - a) * dot(c - a, b - a) / dot(b - a, b - a);
}
PT ProjectPointSegment(PT a, PT b, PT c) {
  double r = dot(b - a, b - a);
  if (fabs(r) < EPS) return a;
  r = dot(c - a, b - a) / r;
  if (r < 0) return a;
  if (r > 1) return b;
  return a + (b - a) * r;
}
double DistancePointSegment(PT a, PT b, PT c) {
  return sqrt(dist2(c, ProjectPointSegment(a, b, c)));
}
double DistancePointPlane(double x, double y, double z, double a, double b,
                          double c, double d) {
  return fabs(a * x + b * y + c * z - d) / sqrt(a * a + b * b + c * c);
}
bool LinesParallel(PT a, PT b, PT c, PT d) {
  return fabs(cross(b - a, c - d)) < EPS;
}
bool LinesCollinear(PT a, PT b, PT c, PT d) {
  return LinesParallel(a, b, c, d) && fabs(cross(a - b, a - c)) < EPS &&
         fabs(cross(c - d, c - a)) < EPS;
}
bool SegmentsIntersect(PT a, PT b, PT c, PT d) {
  if (LinesCollinear(a, b, c, d)) {
    if (dist2(a, c) < EPS || dist2(a, d) < EPS || dist2(b, c) < EPS ||
        dist2(b, d) < EPS)
      return true;
    if (dot(c - a, c - b) > 0 && dot(d - a, d - b) > 0 && dot(c - b, d - b) > 0)
      return false;
    return true;
  }
  if (cross(d - a, b - a) * cross(c - a, b - a) > 0) return false;
  if (cross(a - c, d - c) * cross(b - c, d - c) > 0) return false;
  return true;
}
PT ComputeLineIntersection(PT a, PT b, PT c, PT d) {
  b = b - a;
  d = c - d;
  c = c - a;
  assert(dot(b, b) > EPS && dot(d, d) > EPS);
  return a + b * cross(c, d) / cross(b, d);
}
PT ComputeCircleCenter(PT a, PT b, PT c) {
  b = (a + b) / 2;
  c = (a + c) / 2;
  return ComputeLineIntersection(b, b + RotateCW90(a - b), c,
                                 c + RotateCW90(a - c));
}
int main() {
  int n;
  double ans;
  PT ini, fim, A, B, C;
  vector<PT> poly, inter;
  cin >> ini.x >> ini.y;
  cin >> fim.x >> fim.y;
  cin >> n;
  poly.resize(n);
  for (int i = 0; i < n; i++) cin >> poly[i].x >> poly[i].y;
  for (int i = 0; i < n; i++) {
    A = poly[i];
    B = poly[(i + 1) % n];
    if (LinesCollinear(ini, fim, A, B)) continue;
    if (SegmentsIntersect(ini, fim, A, B)) {
      PT I = ComputeLineIntersection(ini, fim, A, B);
      if (inter.size() == 1 && fabs(I.x - inter[0].x) < EPS &&
          fabs(I.y - inter[0].y) < EPS)
        continue;
      inter.push_back(I);
    }
  }
  ans = sqrt(dist2(ini, fim));
  if (inter.size() < 2) {
    printf("%.9lf\n", ans);
    return 0;
  }
  if (dist2(ini, inter[1]) < dist2(ini, inter[0])) {
    PT tmp = inter[0];
    inter[0] = inter[1];
    inter[1] = tmp;
  }
  double d1 = 0.0, d2 = 0.0;
  int cnt = 0, ok = 0;
  bool used[2];
  used[0] = used[1] = false;
  for (int i = 0; i < n; i++) {
    A = poly[i];
    B = poly[(i + 1) % n];
    if (LinesParallel(inter[0], A, inter[0], B) && !used[0]) {
      ok = 1;
      C = inter[0];
      used[0] = true;
    } else if (LinesParallel(inter[1], A, inter[1], B) && !used[1]) {
      ok = 1;
      C = inter[1];
      used[1] = true;
    }
    if (ok) {
      ok = 0;
      if (!cnt)
        d1 += sqrt(dist2(C, B));
      else
        d1 += sqrt(dist2(A, C));
      cnt++;
      if (cnt == 2) break;
    } else if (cnt == 1)
      d1 += sqrt(dist2(A, B));
  }
  for (int i = 0; i < n; i++) d2 += sqrt(dist2(poly[i], poly[(i + 1) % n]));
  d2 -= d1;
  double d3 = 2.0 * sqrt(dist2(inter[0], inter[1]));
  ans = sqrt(dist2(ini, inter[0])) + sqrt(dist2(inter[1], fim));
  ans += min(d1, min(d2, d3));
  printf("%.9lf\n", ans);
  return 0;
}