#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
const int maxn = 105;
struct point {
  long double x, y;
  point(long double _x = 0, long double _y = 0) : x(_x), y(_y) {}
  void print() { printf("(%.5f %.5f)\n", double(x), double(y)); }
};
bool operator==(const point& a, const point& b) {
  return fabs(a.x - b.x) < eps && fabs(a.y - b.y) < eps;
}
long double dist(point a, point b) {
  return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
bool btw(long double x, long double lx, long double rx) {
  if (lx > rx) swap(lx, rx);
  return lx < x + eps && x < rx + eps;
}
bool btw(point a, point la, point ra) {
  return btw(a.x, la.x, ra.x) && btw(a.y, la.y, ra.y);
}
bool inter(point a1, point b1, point a2, point b2, point& p) {
  long double A1 = b1.y - a1.y, B1 = a1.x - b1.x, C1 = A1 * a1.x + B1 * a1.y;
  long double A2 = b2.y - a2.y, B2 = a2.x - b2.x, C2 = A2 * a2.x + B2 * a2.y;
  long double D = A1 * B2 - A2 * B1;
  if (fabs(D) < eps) return false;
  p.x = (C1 * B2 - C2 * B1) / D;
  p.y = (A1 * C2 - A2 * C1) / D;
  if (btw(p, a1, b1) && btw(p, a2, b2)) return true;
  return false;
}
point read() {
  int x, y;
  scanf("%d %d", &x, &y);
  return point(x, y);
}
point a[maxn];
point s, t;
int n;
long double solve() {
  long double tot = 0;
  for (int i = 0; i < (n); ++i) tot += dist(a[i], a[(i + 1) % n]);
  vector<point> p;
  vector<point> b;
  vector<int> w;
  for (int i = 0; i < (n); ++i) {
    point q;
    b.push_back(a[i]);
    if (inter(s, t, a[i], a[(i + 1) % n], q)) {
      int ok = 1;
      for (__typeof((p).begin()) it = (p).begin(); it != (p).end(); ++it)
        if ((*it) == q) ok = 0;
      if (ok) {
        p.push_back(q), w.push_back(int((b).size())), b.push_back(q);
      }
    }
  }
  if (int((p).size()) < 2) return dist(s, t);
  assert(int((p).size()) == 2);
  long double d1 = 0, d2 = 0;
  for (int i = w[0]; i < w[1]; ++i) d1 += dist(b[i], b[i + 1]);
  d2 = tot - d1;
  long double res = 2 * dist(p[0], p[1]);
  res = min(res, d1);
  res = min(res, d2);
  res += min(dist(s, p[0]) + dist(t, p[1]), dist(s, p[1]) + dist(t, p[0]));
  return res;
}
int main() {
  s = read(), t = read();
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) a[i] = read();
  printf("%.10f\n", double(solve()));
  return 0;
}
