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;
int cmpf(double a, double b = 0) {
  double d = a - b;
  if (d < 1e-6 && d > -(1e-6)) return 0;
  if (d < 0) return -1;
  return 1;
}
struct point {
  double x, y;
  point(double x = 0, double y = 0) : x(x), y(y) {}
  point operator+(point q) { return point(x + q.x, y + q.y); }
  point operator-(point q) { return point(x - q.x, y - q.y); }
  point operator*(double t) { return point(x * t, y * t); }
  point operator/(double t) { return point(x / t, y / t); }
  double operator*(point q) { return x * q.x + y * q.y; }
  double operator%(point q) { return x * q.y - y * q.x; }
  int cmp(point q) const {
    if (int t = cmpf(x, q.x)) return t;
    return cmpf(y, q.y);
  }
  bool operator==(point q) const { return cmp(q) == 0; }
  bool operator!=(point q) const { return cmp(q) != 0; }
  bool operator<(point q) const { return cmp(q) < 0; }
  friend ostream& operator<<(ostream& o, point p) {
    return o << "(" << p.x << ", " << p.y << ")";
  }
  static point pivot;
};
double dist(point p, point q) {
  return sqrt(pow(p.x - q.x, 2) + pow(p.y - q.y, 2));
}
double cross(point p, point q, point r) { return (p - r) % (q - r); }
int ccw(point p, point q, point r) { return cmpf(cross(p, q, r)); }
point rotate(point p, double theta) {
  double rad = theta * 3.14159265359 / 180;
  return point(p.x * cos(rad) - p.y * sin(rad),
               p.x * sin(rad) + p.y * cos(rad));
}
double angle(point a, point b, point c) {
  point u = b - a, v = c - a;
  return acos((u * v) / sqrt((u * u) * (v * v)));
}
bool between(point p, point q, point r) {
  return ccw(p, q, r) == 0 && cmpf((p - q) * (r - q)) <= 0;
}
bool seg_intersect(point p, point q, point r, point s) {
  point A = q - p, B = s - r, C = r - p, D = s - q;
  int a = cmpf(A % C) + 2 * cmpf(A % D);
  int b = cmpf(B % C) + 2 * cmpf(B % D);
  if (a == 3 || a == -3 || b == 3 || b == -3) return false;
  if (a || b || p == r || p == s || q == r || q == s) return true;
  int t = (p < r) + (p < s) + (q < r) + (q < s);
  return t != 0 && t != 4;
}
point pt_seg_intersect(point p, point q, point r, point s) {
  double c = s % r, u = p % s + r % p, v = q % s + r % q;
  u = fabs(u + c);
  v = fabs(v + c);
  return point((p.x * v + q.x * u) / (u + v), (p.y * v + q.y * u) / (u + v));
}
int in_poly(vector<point>& T, point p) {
  double a = 0;
  int N = T.size();
  for (int i = 0; i < N; i++) {
    if (between(T[i], p, T[(i + 1) % N])) return -1;
    a += angle(p, T[i], T[(i + 1) % N]);
  }
  return !cmpf(a - 2 * 3.14159265359) || !cmpf(a + 2 * 3.14159265359);
}
double area_poly(vector<point>& T) {
  double result = 0.0;
  for (int i = 0; i < T.size() - 1; ++i) result += T[i] % T[i + 1];
  result += T[T.size() - 1] % T[0];
  return fabs(result) / 2.0;
}
double perimeter_poly(vector<point>& T) {
  double result = 0.0;
  for (int i = 0; i < T.size() - 1; ++i) result += dist(T[i], T[i + 1]);
  result += dist(T[T.size() - 1], T[0]);
  return fabs(result);
}
pair<vector<point>, vector<point> > cut_poly(vector<point> T, point a,
                                             point b) {
  pair<vector<point>, vector<point> > P;
  double lf1, lf2;
  T.push_back(T.front());
  lf2 = cross(a, b, T[0]);
  for (int i = 0; i < T.size(); ++i) {
    lf1 = lf2;
    lf2 = 0.0;
    if (i != T.size() - 1) lf2 = cross(a, b, T[i + 1]);
    if (lf1 > 1e-6)
      P.first.push_back(T[i]);
    else if (!cmpf(lf1)) {
      P.first.push_back(T[i]);
      P.second.push_back(T[i]);
    } else
      P.second.push_back(T[i]);
    if (lf1 * lf2 < -1e-6) {
      point tmp = pt_seg_intersect(a, b, T[i], T[i + 1]);
      P.first.push_back(tmp);
      P.second.push_back(tmp);
    }
  }
  if (!P.first.empty())
    if (P.first.back() == P.first.front()) P.first.pop_back();
  if (!P.second.empty())
    if (P.second.back() == P.second.front()) P.second.pop_back();
  return P;
}
int main() {
  point b, e;
  int n;
  vector<point> T(40);
  vector<point> pts;
  scanf("%lf %lf %lf %lf %d", &b.x, &b.y, &e.x, &e.y, &n);
  T.clear();
  T.resize(n);
  for (int i = 0; i < n; ++i) {
    scanf("%lf %lf", &T[i].x, &T[i].y);
  }
  for (int i = 0; i < n - 1; ++i) {
    if (seg_intersect(b, e, T[i], T[i + 1]))
      pts.push_back(pt_seg_intersect(b, e, T[i], T[i + 1]));
  }
  if (seg_intersect(b, e, T[n - 1], T[0]))
    pts.push_back(pt_seg_intersect(b, e, T[n - 1], T[0]));
  for (int i = 0; i < pts.size(); ++i) {
    for (int j = i + 1; j < pts.size(); ++j) {
      if (pts[i] == pts[j]) {
        pts.erase(pts.begin() + j);
        if (pts.size() == 1) pts.erase(pts.begin());
      }
    }
  }
  double r;
  if (pts.size() == 1) {
    if (in_poly(T, b) == 1)
      r = 2 * dist(b, pts[0]) + dist(pts[0], e);
    else
      r = dist(b, pts[0]) + 2 * dist(pts[0], e);
  } else if (pts.size() == 2) {
    double d = dist(pts[0], pts[1]);
    pair<vector<point>, vector<point> > pp = cut_poly(T, b, e);
    r = min(perimeter_poly(pp.first) - d, perimeter_poly(pp.second) - d);
    r = min(r, 2 * d);
    double db1 = dist(b, pts[0]), db2 = dist(b, pts[1]);
    if (cmpf(db1, db2) == -1)
      r += db1 + dist(pts[1], e);
    else
      r += db2 + dist(pts[0], e);
  } else {
    if (in_poly(T, b) == 1)
      r = 2 * dist(b, e);
    else
      r = dist(b, e);
  }
  printf("%.9lf\n", r);
  return 0;
}