#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
A convert(B x) {
  stringstream s;
  s << x;
  A r;
  s >> r;
  return r;
}
pair<double, double> st, fn;
vector<pair<double, double> > p, po;
double d[33][33];
int n;
double Dist(pair<double, double> p1, pair<double, double> p2) {
  return sqrt(((p1.first - p2.first) * (p1.first - p2.first)) +
              ((p1.second - p2.second) * (p1.second - p2.second)));
}
int Sign(double a) {
  if (abs(a) < 1e-9) return 0;
  if (a > 0) return +1;
  if (a < 0) return -1;
}
void getABC(pair<double, double> p1, pair<double, double> p2, double& a,
            double& b, double& c) {
  a = p2.second - p1.second;
  b = p1.first - p2.first;
  c = -a * p1.first - b * p1.second;
}
bool SegmLineIntersect(pair<double, double> s11, pair<double, double> s12,
                       pair<double, double> s21, pair<double, double> s22) {
  double a, b, c;
  getABC(s11, s12, a, b, c);
  return Sign(a * s21.first + b * s21.second + c) *
             Sign(a * s22.first + b * s22.second + c) <
         0;
}
bool SegmSegmIntersect(pair<double, double> s11, pair<double, double> s12,
                       pair<double, double> s21, pair<double, double> s22) {
  return SegmLineIntersect(s11, s12, s21, s22) &&
         SegmLineIntersect(s21, s22, s11, s12);
}
pair<double, double> getLineLineIntersect(pair<double, double> s11,
                                          pair<double, double> s12,
                                          pair<double, double> s21,
                                          pair<double, double> s22) {
  double A1, B1, C1;
  getABC(s11, s12, A1, B1, C1);
  double A2, B2, C2;
  getABC(s21, s22, A2, B2, C2);
  double det = A1 * B2 - A2 * B1;
  pair<double, double> res =
      make_pair((B1 * C2 - B2 * C1) / det, (A1 * C2 - A2 * C1) / -det);
  return res;
}
bool Eq(pair<double, double> p1, pair<double, double> p2) {
  return abs(p1.first - p2.first) < 1e-8 && abs(p1.second - p2.second) < 1e-8;
}
bool Can(pair<double, double> ot, pair<double, double> ku) {
  for (int i = (0), _b(((int)(po).size())); i < _b; ++i)
    for (int j = (i + 1), _b(((int)(po).size())); j < _b; ++j)
      if (SegmSegmIntersect(ot, ku, po[i], po[j])) return false;
  return true;
}
bool isOn(pair<double, double> p1, pair<double, double> p2,
          pair<double, double> p) {
  double a, b, c;
  getABC(p1, p2, a, b, c);
  return !Sign(a * p.first + b * p.second + c);
}
int main() {
  cin >> st.first >> st.second;
  cin >> fn.first >> fn.second;
  cin >> n;
  p.resize(n);
  for (int i = (0), _b(n); i < _b; ++i) cin >> p[i].first >> p[i].second;
  for (int i = (n)-1, _a(0); i >= _a; --i) {
    pair<double, double> p1 = p[i];
    pair<double, double> p2 = p[(i + 1) % ((int)(p).size())];
    pair<double, double> res((p1.first + p2.first) / 2.,
                             (p1.second + p2.second) / 2.);
    p.insert(p.begin() + i + 1, res);
  }
  po = p;
  n = ((int)(p).size());
  if (Can(st, fn)) {
    printf("%.8lf\n", Dist(st, fn));
    return 0;
  }
  for (int i = (n)-1, _a(0); i >= _a; --i) {
    if (SegmSegmIntersect(st, fn, p[i], p[(i + 1) % n]))
      p.insert(p.begin() + i + 1,
               getLineLineIntersect(st, fn, p[i], p[(i + 1) % n]));
  }
  n = ((int)(p).size());
  for (int i = (0), _b(n); i < _b; ++i)
    for (int j = (0), _b(n); j < _b; ++j)
      if (i == j)
        d[i][j] = 0;
      else if (abs(i - j) == 1 || (i == 0 && j == n - 1) ||
               (i == n - 1 && j == 0))
        d[i][j] = Dist(p[i], p[j]);
      else
        d[i][j] = 2. * Dist(p[i], p[j]);
  for (int ch = (0), _b(n); ch < _b; ++ch)
    for (int ot = (0), _b(n); ot < _b; ++ot)
      for (int ku = (0), _b(n); ku < _b; ++ku)
        d[ot][ku] = min(d[ot][ku], d[ot][ch] + d[ch][ku]);
  double res = 1e20;
  for (int i = (0), _b(n); i < _b; ++i)
    if (Can(st, p[i]) && isOn(st, fn, p[i]))
      for (int j = (0), _b(n); j < _b; ++j)
        if (Can(p[j], fn) && isOn(st, fn, p[j]))
          res = min(res, Dist(st, p[i]) + d[i][j] + Dist(p[j], fn));
  cout << fixed << setprecision(10) << res << endl;
  return 0;
}
