#include <bits/stdc++.h>
using namespace std;
using namespace rel_ops;
const double PI = acos((double)-1);
int ts, ts2, ts3, ts4;
double sqr(double x) { return x * x; }
int n, m;
class point {
 public:
  double x, y;
  point() { x = y = 0; }
  point(double a, double b) { x = a, y = b; }
  inline friend point operator+(const point &A, const point &B) {
    return point(A.x + B.x, A.y + B.y);
  }
  inline friend point operator-(const point &A, const point &B) {
    return point(A.x - B.x, A.y - B.y);
  }
  inline friend point operator*(const point &A, double p) {
    return point(A.x * p, A.y * p);
  }
  inline friend point operator/(const point &A, double p) {
    return point(A.x / p, A.y / p);
  }
  inline friend void operator+=(point &A, const point &B) { A = A + B; }
  inline friend void operator-=(point &A, const point &B) { A = A - B; }
  inline friend void operator*=(point &A, double B) { A = A * B; }
  inline friend void operator/=(point &A, double B) { A = A / B; }
  inline friend bool operator<(const point &A, const point &B) {
    return A.x < B.x - 1E-10 || fabs(A.x - B.x) < 1E-10 && A.y + 1E-10 < B.y;
  }
  inline friend bool operator==(const point &A, const point &B) {
    return !(A < B || B < A);
  }
  inline friend bool operator>(const point &A, const point &B) { return B < A; }
};
class XL {
 public:
  point a, b;
  XL() {}
  XL(point x, point y) {
    a = x;
    b = y;
  }
  XL(double t1, double t2, double t3, double t4) {
    a.x = t1;
    a.y = t2;
    b.x = t3;
    b.y = t4;
  }
};
inline double gag(double x) {
  if (x < -PI - 1E-10) return gag(x + 2 * PI);
  if (x > PI - 1E-10) return gag(x - 2 * PI);
  return x;
}
inline double gag2(double x) {
  if (x < -1E-10) return gag2(x + 2 * PI);
  if (x > 2 * PI - 1E-10) return gag2(x - 2 * PI);
  return x;
}
inline double chaji(const point &A, const point &B) {
  return A.x * B.y - B.x * A.y;
}
inline double dianji(const point &A, const point &B) {
  return A.x * B.x + A.y * B.y;
}
inline double dis(const point &A, const point &B) {
  return sqrt(sqr(A.x - B.x) + sqr(A.y - B.y));
}
inline double dis(const XL &A) { return dis(A.a, A.b); }
inline double dis(const point &A) { return sqrt(sqr(A.x) + sqr(A.y)); }
inline double atan2(const point &A) { return gag(atan2(A.y, A.x)); }
inline point shengcheng(double JD, double CD = 1.0) {
  return point(cos(JD) * CD, sin(JD) * CD);
}
inline short sgn(double x) {
  if (fabs(x) < 1E-10)
    return 0;
  else if (x < 0)
    return -1;
  else
    return 1;
}
point poo = point(200000000000000000ll, 200000000000000000ll);
point cross(XL a, XL b) {
  double u1 = chaji(b.a - a.a, b.b - a.a), u2 = chaji(b.b - a.b, b.a - a.b);
  if (u1 + u2 == 0) return poo;
  return a.a + (a.b - a.a) * (u1 / (u1 + u2));
}
int online(point x, XL a) {
  return dis(x - a.b) + dis(a.a - x) <= dis(a) + 1E-10;
}
int iscross(XL a, XL b) {
  point pp = cross(a, b);
  return pp != poo && online(pp, a) && online(pp, b) && dis(pp - a.a) > 1E-10;
}
long long gcd(long long x, long long y) {
  long long t;
  for (; y != 0;) {
    t = x % y;
    x = y;
    y = t;
  }
  return x;
}
point st, en, a[1005];
void input(point &x) { cin >> x.x >> x.y; }
point cr[10];
int cr_, cr1[10];
int main() {
  int i, j, k, l, t1, t2, t3, t4, t5, t6, t7, t8, t9, t, nw;
  int tt1, tt2, tt3, tt4;
  double u1, u2, u3, u4, u5, u6, u7, u8, u9;
  char c1, c2, c3;
  srand((unsigned)time(0));
  input(st);
  input(en);
  cin >> n;
  for (i = 1; i <= n; i++) input(a[i]), a[i + n] = a[i];
  a[n + 1] = a[1];
  a[0] = a[n];
  point p;
  for (i = 1; i <= n; i++)
    if (p = cross(XL(a[i], a[i + 1]), XL(st, en)),
        (iscross(XL(a[i], a[i + 1]), XL(st, en)))) {
      cr[++cr_] = p;
      cr1[cr_] = i;
    }
  cout << setprecision(10) << fixed;
  double ans = 2000000000;
  if (cr_ == 0 || cr_ == 1) {
    cout << dis(st - en) << endl;
    return 0;
  }
  if (dis(cr[1] - st) > dis(cr[2] - st))
    swap(cr[1], cr[2]), swap(cr1[1], cr1[2]);
  ans = min(ans, dis(cr[1] - st) + dis(cr[2] - en) + dis(cr[1] - cr[2]) * 2);
  u1 = 0;
  t1 = cr1[1], t2 = cr1[2];
  if (t2 < t1) t2 += n;
  u1 += dis(cr[1] - st) + dis(cr[2] - en) + dis(cr[1] - a[t1 + 1]) +
        dis(cr[2] - a[t2]);
  for (i = t1 + 1; i <= t2 - 1; i++) u1 += dis(a[i] - a[i + 1]);
  ans = min(ans, u1);
  u1 = 0;
  t1 = cr1[1] + 1, t2 = cr1[2] + 1;
  if (t1 < t2) t1 += n;
  u1 += dis(cr[1] - st) + dis(cr[2] - en) + dis(cr[1] - a[t1 - 1]) +
        dis(cr[2] - a[t2]);
  for (i = t2 + 1; i <= t1 - 1; i++) u1 += dis(a[i] - a[i - 1]);
  ans = min(ans, u1);
  cout << ans << endl;
  return 0;
}
