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
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 32;
const int Maxm = 105;
const long double eps = 1e-11l;
const long double Inf = 1e30l;
int xs, ys, xe, ye;
int n;
int x[Maxn], y[Maxn];
pair<long double, long double> pnt[Maxm];
int plen;
long double dist[Maxm][Maxm];
void Get(long double x1, long double y1, long double x2, long double y2,
         long double &A, long double &B, long double &C) {
  A = y2 - y1, B = x1 - x2, C = A * x1 + B * y1;
}
bool Equal(long double x, long double y, long double X, long double Y) {
  return fabs(x - X) < eps && fabs(y - Y) < eps;
}
bool Intersect(long double x1, long double y1, long double x2, long double y2,
               long double x3, long double y3, long double x4, long double y4,
               bool strict, long double &X, long double &Y) {
  long double A1, B1, C1;
  Get(x1, y1, x2, y2, A1, B1, C1);
  long double A2, B2, C2;
  Get(x3, y3, x4, y4, A2, B2, C2);
  long double det = A1 * B2 - A2 * B1;
  if (fabs(det) < eps) return false;
  X = (B2 * C1 - B1 * C2) / det;
  Y = (A1 * C2 - A2 * C1) / det;
  if (Equal(x1, y1, X, Y) || Equal(x2, y2, X, Y)) return false;
  if (strict && (Equal(x3, y3, X, Y) || Equal(x4, y4, X, Y))) return false;
  return min(x1, x2) <= X + eps && X <= max(x1, x2) + eps &&
         min(y1, y2) <= Y + eps && Y <= max(y1, y2) + eps &&
         min(x3, x4) <= X + eps && X <= max(x3, x4) + eps &&
         min(y3, y4) <= Y + eps && Y <= max(y3, y4) + eps;
}
long double Dist(long double ax, long double ay) {
  return sqrt(ax * ax + ay * ay);
}
bool testOutside(long double x1, long double y1) {
  long double x2 = 1000000 + rand(), y2 = rand();
  int tims = 0;
  long double X, Y;
  for (int i = 0; i < n; i++)
    if (Intersect(x1, y1, x2, y2, x[i], y[i], x[(i + 1) % n], y[(i + 1) % n],
                  false, X, Y))
      tims++;
  return tims % 2 == 0;
}
bool onLine(long double X, long double Y, long double x1, long double y1,
            long double x2, long double y2) {
  long double ax = x1 - X, ay = y1 - Y;
  long double bx = x2 - X, by = y2 - Y;
  return fabs(ax * by - ay * bx) < eps;
}
int Koef(long double x1, long double y1, long double x2, long double y2) {
  long double X, Y;
  for (int i = 0; i < n; i++)
    if (Intersect(x1, y1, x2, y2, x[i], y[i], x[(i + 1) % n], y[(i + 1) % n],
                  true, X, Y))
      return 2;
  long double p = rand() + 1;
  long double tx = (x1 + p * x2) / (p + 1.0l), ty = (y1 + p * y2) / (p + 1.0l);
  return testOutside(tx, ty) ? 1 : 2;
}
bool Less(const pair<long double, long double> &a,
          const pair<long double, long double> &b) {
  return Dist(xs - a.first, ys - a.second) < Dist(xs - b.first, ys - b.second);
}
int main() {
  scanf("%d %d %d %d", &xs, &ys, &xe, &ye);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d %d", &x[i], &y[i]);
  fill((long double *)dist, (long double *)dist + Maxm * Maxm, Inf);
  pnt[plen++] = pair<long double, long double>(xs, ys);
  pnt[plen++] = pair<long double, long double>(xe, ye);
  for (int i = 0; i < n; i++) {
    pnt[plen++] = pair<long double, long double>(x[i], y[i]);
    if (i + 1 < n)
      dist[plen - 1][plen] = dist[plen][plen - 1] =
          Dist(x[i] - x[i + 1], y[i] - y[i + 1]);
    else
      dist[plen - 1][2] = dist[2][plen - 1] = Dist(x[i] - x[0], y[i] - y[0]);
  }
  for (int i = 0; i < n; i++) {
    long double X, Y;
    if (Intersect(xs, ys, xe, ye, x[i], y[i], x[(i + 1) % n], y[(i + 1) % n],
                  false, X, Y))
      pnt[plen++] = pair<long double, long double>(X, Y);
  }
  sort(pnt + n + 2, pnt + plen, Less);
  if (plen == n + 2) {
    cout << fixed << setprecision(10) << Dist(xs - xe, ys - ye) << endl;
    return 0;
  }
  dist[0][n + 2] = dist[n + 2][0] =
      Dist(xs - pnt[n + 2].first, ys - pnt[n + 2].second);
  dist[plen - 1][1] = dist[1][plen - 1] =
      Dist(pnt[plen - 1].first - xe, pnt[plen - 1].second - ye);
  for (int i = n + 2; i + 1 < plen; i++)
    dist[i][i + 1] = dist[i + 1][i] =
        Koef(pnt[i].first, pnt[i].second, pnt[i + 1].first, pnt[i + 1].second) *
        Dist(pnt[i].first - pnt[i + 1].first,
             pnt[i].second - pnt[i + 1].second);
  for (int i = n + 2; i < plen; i++)
    for (int j = 0; j < n; j++) {
      int nj = (j + 1) % n;
      long double x1 = x[j], y1 = y[j], x2 = x[nj], y2 = y[nj];
      if (onLine(pnt[i].first, pnt[i].second, x1, y1, x2, y2) &&
          min(x1, x2) <= pnt[i].first + eps &&
          pnt[i].first <= max(x1, x2) + eps &&
          min(y1, y2) <= pnt[i].second + eps &&
          pnt[i].second <= max(y1, y2) + eps) {
        dist[i][2 + j] = dist[2 + j][i] =
            Dist(pnt[i].first - x1, pnt[i].second - y1);
        dist[i][2 + nj] = dist[2 + nj][i] =
            Dist(pnt[i].first - x2, pnt[i].second - y2);
      }
    }
  for (int k = 0; k < plen; k++)
    for (int i = 0; i < plen; i++)
      for (int j = 0; j < plen; j++)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  cout << fixed << setprecision(10) << dist[0][1] << endl;
  return 0;
}
