#include <bits/stdc++.h>
using namespace std;
template <typename point_type>
struct point {
  point_type x, y;
  point() { x = 0, y = 0; }
  point(point_type xx, point_type yy) { x = xx, y = yy; }
  template <typename point_type2>
  point(point<point_type2> from) {
    x = from.x, y = from.y;
  }
  point operator-(point second) { return point(x - second.x, y - second.y); }
  bool operator<(point second) {
    return make_pair(x, y) < make_pair(second.x, second.y);
  }
};
template <typename point_type>
double find_distance(point<point_type> p1, point<point_type> p2) {
  return hypot(p1.x - p2.x, p1.y - p2.y);
}
template <typename point_type>
struct segment {
  point<point_type> p1, p2;
  segment() { p1 = point<point_type>(), p2 = point<point_type>(); }
  segment(point<point_type> pp1, point<point_type> pp2) { p1 = pp1, p2 = pp2; }
  double length() { return find_distance(p1, p2); }
};
template <typename point_type>
struct line {
  point_type a, b, c;
  line() { a = 0, b = 0, c = 0; }
  line(point<point_type> pp1, point<point_type> pp2) {
    a = pp1.y - pp2.y;
    b = pp2.x - pp1.x;
    c = -(a * pp1.x + b * pp1.y);
  }
};
template <typename arg_type>
arg_type cross_product(point<arg_type> a, point<arg_type> b) {
  return a.x * b.y - b.x * a.y;
}
template <typename point_type>
istream &operator>>(istream &in, point<point_type> &input_point) {
  in >> input_point.x >> input_point.y;
  return in;
}
template <typename line_type>
point<double> line_intersection(line<line_type> line1, line<line_type> line2) {
  double divisor = line1.a * line2.b - line1.b * line2.a;
  return point<double>((line1.b * line2.c - line2.b * line1.c) / divisor,
                       (line2.a * line1.c - line1.a * line2.c) / divisor);
}
template <typename num_type>
int sign(num_type number) {
  return number == 0 ? 0 : abs(number) / number;
}
template <typename segment_type>
pair<int, point<double> > segment_intersection(segment<segment_type> segment1,
                                               segment<segment_type> segment2) {
  segment_type cross_product1 = cross_product(segment2.p1 - segment1.p1,
                                              segment1.p2 - segment1.p1),
               cross_product2 = cross_product(segment2.p2 - segment1.p1,
                                              segment1.p2 - segment1.p1),
               cross_product3 = cross_product(segment1.p1 - segment2.p1,
                                              segment2.p2 - segment2.p1),
               cross_product4 = cross_product(segment1.p2 - segment2.p1,
                                              segment2.p2 - segment2.p1),
               cross_product5 = cross_product(segment1.p2 - segment1.p1,
                                              segment2.p2 - segment2.p1);
  if (cross_product5 == 0 || cross_product1 == 0)
    return make_pair(-1, point<double>());
  if (sign(cross_product1) != sign(cross_product2) &&
      sign(cross_product3) != sign(cross_product4)) {
    line<segment_type> line1(segment1.p1, segment1.p2),
        line2(segment2.p1, segment2.p2);
    return make_pair(0, line_intersection(line1, line2));
  } else
    return make_pair(-1, point<double>());
}
int main() {
  cout << fixed << setprecision(6);
  point<int> point_strt, point_end, vertex[50];
  int vertex_number;
  cin >> point_strt >> point_end;
  cin >> vertex_number;
  for (int i = 0; i < vertex_number; i++) cin >> vertex[i];
  double perimeter = 0;
  segment<int> main_segment(point_strt, point_end);
  pair<int, point<double> > intersection1, intersection2;
  intersection1.first = intersection2.first = -1;
  for (int i = 0; i < vertex_number; i++) {
    segment<int> current_segment(vertex[i], vertex[(i + 1) % vertex_number]);
    perimeter += current_segment.length();
    if (intersection1.first == -1) {
      intersection1 = segment_intersection(main_segment, current_segment);
      if (intersection1.first == 0) intersection1.first = i;
    } else if (intersection2.first == -1) {
      intersection2 = segment_intersection(main_segment, current_segment);
      if (intersection2.first == 0) intersection2.first = i;
    }
  }
  double way = main_segment.length();
  if (intersection2.first > -1) {
    double through = find_distance(intersection1.second, intersection2.second);
    way -= through;
    double half1 =
        find_distance(
            intersection1.second,
            point<double>(vertex[(intersection1.first + 1) % vertex_number])) +
        find_distance(intersection2.second,
                      point<double>(vertex[intersection2.first]));
    for (int i = (intersection1.first + 1) % vertex_number;
         i != intersection2.first; i = (i + 1) % vertex_number)
      half1 += find_distance(vertex[i], vertex[(i + 1) % vertex_number]);
    double half2 = perimeter - half1;
    way += min(min(half1, half2), through * 2);
  }
  cout << way;
  return 0;
}
