#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
int n;
double s[52];
struct point {
  double x, y;
} A, B, P[52];
inline double min(double x, double y) { return x < y ? x : y; }
double cross(point O, point A, point B) {
  return (A.x - O.x) * (B.y - O.y) - (A.y - O.y) * (B.x - O.x);
}
double dot(point O, point B, point C) {
  return (A.x - O.x) * (B.x - O.x) + (A.y - O.y) * (B.y - O.y);
}
double dist(point A, point B) {
  return sqrt((B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y));
}
double calc(double per) {
  int id = per;
  return s[id] + dist(P[id], P[id + 1]) * (per - id);
}
int main() {
  scanf("%lf%lf%lf%lf", &A.x, &A.y, &B.x, &B.y);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lf%lf", &P[i].x, &P[i].y);
  P[n] = P[0];
  for (int i = 0; i < n; i++) s[i + 1] = s[i] + dist(P[i], P[i + 1]);
  double low = 1e100, high = 0, minp = 0, maxp = 0;
  for (int i = 0; i < n; i++)
    if (abs(cross(A, B, P[i])) < eps && dot(A, B, P[i]) > eps &&
        dot(B, A, P[i]) > eps) {
      double fac = dist(A, P[i]) / dist(A, B);
      if (fac > high) high = fac, maxp = i;
      if (fac < low) low = fac, minp = i;
    }
  for (int i = 0; i < n; i++) {
    if (cross(A, B, P[i]) * cross(A, B, P[i + 1]) < eps &&
        cross(P[i], P[i + 1], A) * cross(P[i], P[i + 1], B) < eps) {
      double fac = cross(P[i], P[i + 1], A) /
                   (cross(P[i], P[i + 1], A) - cross(P[i], P[i + 1], B));
      double per =
          i + cross(A, B, P[i]) / (cross(A, B, P[i]) - cross(A, B, P[i + 1]));
      if (fac > high) high = fac, maxp = per;
      if (fac < low) low = fac, minp = per;
    }
  }
  if (low > high)
    printf("%.9lf", dist(A, B));
  else {
    double l = calc(minp), r = calc(maxp), t;
    if (l > r) t = l, l = r, r = t;
    printf("%.9lf",
           min(dist(A, B) * (1 + high - low),
               dist(A, B) * (1 - high + low) + min(r - l, s[n] - r + l)));
  }
}
