#include <bits/stdc++.h>   using namespace std;   long long read() {     long long ret = 0, f = 1;     char x = getchar();     while (!(x >=  0  && x <=  9 )) {       if (x ==  - ) f = -1;       x = getchar();     }     while (x >=  0  && x <=  9 ) ret = ret * 10 + x -  0 , x = getchar();     return ret * f;   }   char get_char() {     char x = getchar();     while (!((x >=  a  && x <=  z ) || (x >=  A  && x <=  Z ))) x = getchar();     return x;   }   const double eps = 1e-10;   int dcmp(double n) {     if (fabs(n) < eps)       return 0;     else if (n < 0)       return -1;     else       return 1;   }   struct point {     double x, y;     point() {}     point(double x, double y) : x(x), y(y) {}     bool operator<(const point& p) const {       if (dcmp(x - p.x) != 0) return x < p.x;       if (dcmp(y - p.y) != 0) return y < p.y;       return false;     }     bool operator==(const point& p) const {       return dcmp(x - p.x) == 0 && dcmp(y - p.y) == 0;     }     void read() { scanf( %lf %lf , &x, &y); }     void print() const { printf( x:%.3lf y:%.3lf n , x, y); }     double len() const { return sqrt(x * x + y * y); }   };   point operator-(const point& a, const point& b) {     return point(a.x - b.x, a.y - b.y);   }   point operator+(const point& a, const point& b) {     return point(a.x + b.x, a.y + b.y);   }   point operator*(double num, const point& a) {     return point(a.x * num, a.y * num);   }   double det(point a, point b) { return a.x * b.y - b.x * a.y; }   double det(point a, point b, point o) { return det(a - o, b - o); }   double dot(point a, point b) { return a.x * b.x + a.y * b.y; }   double ang(point a, point b) {     double cosx = dot(a, b) / (a.len() * b.len());     return acos(cosx);   }   point rotate(point p, double d) {     double tx = cos(d) * p.x - sin(d) * p.y;     double ty = sin(d) * p.x + cos(d) * p.y;     return point(tx, ty);   }   bool on_line(point p, point a, point b) {     if (b < a) swap(a, b);     if (dcmp(p.x - a.x) < 0 || dcmp(b.x - p.x) > 0) return false;     int m = dcmp(det(b - a, p - a));     return m == 0;   }   bool is_inter(point a1, point a2, point b1, point b2) {     int m1 = dcmp(det(a2, b1, a1));     int m2 = dcmp(det(a2, b2, a1));     int m3 = dcmp(det(b2, a1, b1));     int m4 = dcmp(det(b2, a2, b1));     return m1 != m2 && m3 != m4;   }   point inter_point(point a1, point a2, point b1, point b2) {     double t = det(a1, b2, b1) / det(b2 - b1, a2 - a1);     return (a1 + t * (a2 - a1));   }   const int L_N = 30 + 10;   const double INF = 1e9;   point S, E;   vector<point> PS;   set<point> INT_SET;   int N;   double dis[L_N][L_N];   bool get_inter() {     for (int i = 0; i < PS.size(); i++) {       int nxt = (i + 1) % PS.size();       if (is_inter(S, E, PS[i], PS[nxt])) {         point t = inter_point(S, E, PS[i], PS[nxt]);         if (INT_SET.count(t)) continue;         INT_SET.insert(t);         PS.insert(PS.begin() + i + 1, t);         return true;       }     }     return false;   }   double get_ans_int() {     point p1, p2;     int sid = 0, eid = 0;     set<point>::iterator it = INT_SET.begin();     p1 = *it;     it++;     p2 = *it;     for (int i = (0); i <= ((int)PS.size() - 1); i++) {       if (PS[i] == p1)         sid = i;       else if (PS[i] == p2)         eid = i;     }     double ans = 2 * (p1 - p2).len();     ans = min(ans, dis[sid][eid]);     ans += min((S - p1).len(), (S - p2).len());     ans += min((E - p1).len(), (E - p2).len());     return ans;   }   int main() {     for (int i = (0); i <= (L_N - 1); i++)       for (int j = (0); j <= (L_N - 1); j++)         if (i != j) dis[i][j] = INF;     S.read(), E.read();     N = read();     PS.resize(N);     for (int i = (0); i <= (N - 1); i++) PS[i].read();     while (get_inter())       ;     for (int i = (0); i <= ((int)PS.size() - 1); i++) {       int nxt = (i + 1) % PS.size();       dis[i][nxt] = dis[nxt][i] = (PS[i] - PS[nxt]).len();     }     for (int k = (0); k <= (N + 2); k++)       for (int i = (0); i <= (N + 2); i++)         for (int j = (0); j <= (N + 2); j++) {           if (dcmp(dis[i][k] + dis[k][j] - dis[i][j]) < 0)             dis[i][j] = dis[i][k] + dis[k][j];         }     double ans = 0;     if (INT_SET.size() < 2)       ans = (S - E).len();     else       ans = get_ans_int();     printf( %.10lf n , ans);   }