Problem: You have got a new job, and it's very interesting, you are a ship captain. Your first task is to move your ship from one point to another point, and for sure you want to move it at the minimum cost.

And it's well known that the shortest distance between any 2 points is the length of the line segment between these 2 points. But unfortunately there is an island in the sea, so sometimes you won't be able to move your ship in the line segment between the 2 points.

You can only move to safe points. A point is called safe if it's on the line segment between the start and end points, or if it's on the island's edge.

But you are too lucky, you have got some clever and strong workers and they can help you in your trip, they can help you move the ship in the sea and they will take 1 Egyptian pound for each moving unit in the sea, and they can carry the ship (yes, they are very strong) and walk on the island and they will take 2 Egyptian pounds for each moving unit in the island. The money which you will give to them will be divided between all workers, so the number of workers does not matter here.

You can move your ship on the island edge, and it will be considered moving in the sea.

Now you have a sea map, and you have to decide what is the minimum cost for your trip.

Your starting point is (xStart, yStart), and the end point is (xEnd, yEnd), both points will be different.

The island will be a convex polygon and there will be no more than 2 polygon points on the same line, also the starting and the end points won't be inside or on the boundary of the island. The points for the polygon will be given in the anti-clockwise order.

Input

The first line contains 4 integers, xStart, yStart, xEnd and yEnd ( - 100 ≤ xStart, yStart, xEnd, yEnd ≤ 100). The second line contains an integer n, which is the number of points in the polygon (3 ≤ n ≤ 30), followed by a line containing n pairs of integers x and y, which are the coordinates of the points ( - 100 ≤ x, y ≤ 100), the polygon points will be distinct.

Output

Print one line which contains the minimum possible cost. The absolute or relative error in the answer should not exceed 10 - 6.

Examples

Input

1 7 6 7
4
4 2 4 12 3 12 3 2


Output

6.000000000


Input

-1 0 2 0
4
0 0 1 0 1 1 0 1


Output

3.000000000

Solution (in JAVA):

Solution:
import java.util.*;
import java.io.*;

import static java.lang.Math.*;

public class Main {

    BufferedReader in;
    StringTokenizer st;
    PrintWriter out;

    static class Point {
        double x, y;

        public Point(double x, double y) {
            this.x = x;
            this.y = y;
        }
    }

    static double sqr(double a) {
        return a * a;
    }

    static double dist(Point p1, Point p2) {
        return sqrt(sqr(p1.x - p2.x) + sqr(p1.y - p2.y));
    }

    static class Segment {
        Point p1, p2;
        double a, b, c;

        double dist() {
            return Main.dist(p1, p2);
        }

        public Segment(Point p1, Point p2) {
            this.p1 = p1;
            this.p2 = p2;
            make(p1, p2);
        }

        void make(Point p1, Point p2) {
            a = p2.y - p1.y;
            b = p1.x - p2.x;
            c = -(p1.x * a + p1.y * b);
        }

        boolean cross(Segment s) {
            double q = a * s.p1.x + b * s.p1.y + c;
            double w = a * s.p2.x + b * s.p2.y + c;
            double e = s.a * p1.x + s.b * p1.y + s.c;
            double r = s.a * p2.x + s.b * p2.y + s.c;
            q = norm(q);
            w = norm(w);
            e = norm(e);
            r = norm(r);
            if (q == 0.0)
                return false;
            if (q * w <= 0 && e * r <= 0) {
                if (q == 0 && w == 0 && e == 0 && r == 0)
                    return false;
                return true;
            }
            return false;
        }

        Point crossPoint(Segment s) {
            double st = -a * s.b + s.a * b;
            double x = (c * s.b - s.c * b) / st;
            double y = (a * s.c - s.a * c) / st;
            return new Point(x, y);
        }
    }

    static double norm(double a) {
        if (a > 0)
            return 1;
        if (a < 0)
            return -1;
        return 0;
    }

    Point start, end;

    int n;
    Point[] polygon;

    Segment[] segms;

    void solve() throws IOException {
        start = new Point(ni(), ni());
        end = new Point(ni(), ni());
        n = ni();
        polygon = new Point[n];
        for (int i = 0; i < polygon.length; i++) {
            polygon[i] = new Point(ni(), ni());
        }
        segms = new Segment[n];
        double hullLen = 0;
        for (int i = 0; i < n; ++i) {
            int j = (i + 1) % n;
            segms[i] = new Segment(polygon[i], polygon[j]);
            hullLen += segms[i].dist();
        }

        Segment line = new Segment(start, end);

        Point p1 = null, p2 = null;
        int id1 = 0, id2 = 0;
        for (int i = 0; i < n; ++i)
            if (line.cross(segms[i])) {
                if (p1 == null) {
                    p1 = line.crossPoint(segms[i]);
                    id1 = i;
                } else {
                    p2 = line.crossPoint(segms[i]);
                    id2 = i;
                }
            }
        double ret = 1e+20;
        if (p1 == null || p2 ==null) {
            ret = line.dist();
        } else {
            double a = dist(start, p1);
            double b = dist(start, p2);
            double c = dist(end, p1);
            double d = dist(end, p2);
            double dist = min(a, b) + min(c, d);
            double d1 = dist(p1, p2) * 2;
            double d2 = lenClockwise(id1, id2, p1, p2);
            double d3 = hullLen - lenClockwise(id1, id2, p1, p2);

            ret = dist + d1;
            if (dist + d2 < ret)
                ret = dist + d2;
            if (dist + d3 < ret)
                ret = dist + d3;
        }
        out.println(ret);
    }

    double lenClockwise(int id1, int id2, Point p1, Point p2) {
        double ret = 0;
        for (int i = (id1 + 1); i < id2; ++i)
            ret += segms[i].dist();
        ret += dist(segms[id1].p2, p1);
        ret += dist(segms[id2].p1, p2);
        return ret;
    }

    public Main() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        in.close();
        out.close();
    }

    String ns() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    int ni() throws IOException {
        return Integer.valueOf(ns());
    }

    long nl() throws IOException {
        return Long.valueOf(ns());
    }

    double nd() throws IOException {
        return Double.valueOf(ns());
    }

    public static void main(String[] args) throws IOException {
        new Main();
    }
}