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 java.math.*;

public class Main {
    public void run() {
        Point start, end;
        start = new Point();
        end = new Point();
        start.x = cin.nextDouble();
        start.y = cin.nextDouble();
        end.x = cin.nextDouble();
        end.y = cin.nextDouble();
        List<Point> L = new ArrayList<Point>();
        int n = cin.nextInt();
        for (int i = 0; i < n; ++i) {
            Point tmp = new Point();
            tmp.x = cin.nextDouble();
            tmp.y = cin.nextDouble();
            L.add(tmp);
        }
        L.add(L.get(0));
        List<Integer> K = new LinkedList<Integer>();
        for (int i = 0; i < L.size() - 1; ++i) {
            if (Point.parallel(start, end, L.get(i), L.get(i + 1)))
                continue;
            if (!Point.intersect_in(start, end, L.get(i), L.get(i + 1)))
                continue;
            Point p = Point.intersection(start, end, L.get(i), L.get(i + 1));
            if (Point.distance(p, L.get(i)) == 0) {
                K.add(i);
            } else if (Point.dot_online_ex(p, L.get(i), L.get(i + 1))) {
                K.add(i + 1);
                L.add(++i, p);
            }
        }

        if (K.size() < 2) {
            System.out.println(Point.distance(start, end));
        } else {
            double ans = 0.0, ret = 0.0;
            int tmp1 = 0, tmp2 = 1;
            if (Point.distance(start, L.get(K.get(tmp1))) > Point.distance(
                    start, L.get(K.get(tmp2)))) {
                int tmp = tmp1;
                tmp1 = tmp2;
                tmp2 = tmp;
            }
            ans = 2 * Point.distance(L.get(K.get(tmp1)), L.get(K.get(tmp2)));
            for (int i = K.get(tmp1); i != K.get(tmp2); i = (i + 1)
                    % (L.size() - 1)) {
                ret += Point
                        .distance(L.get(i), L.get((i + 1) % (L.size() - 1)));
            }
            ans = Math.min(ans, ret);
            ret = 0.0;
            for (int i = K.get(tmp2); i != K.get(tmp1); i = (i + 1)
                    % (L.size() - 1)) {
                ret += Point
                        .distance(L.get(i), L.get((i + 1) % (L.size() - 1)));
            }
            ans = Math.min(ans, ret);
            ans += Point.distance(start, L.get(K.get(tmp1)));
            ans += Point.distance(end, L.get(K.get(tmp2)));
            System.out.println(ans);
        }

    }

    public static void main(String[] argv) {
        new Main().run();
    }

    Scanner cin = new Scanner(System.in);
}

class Point {
    static final double EPS = 1e-8;
    double x, y;

    Point() {
    }

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

    Point(Point u) {
        this.x = u.x;
        this.y = u.y;
    }

    public static boolean parallel(Point u1, Point u2, Point v1, Point v2) {
        return zero((u1.x - u2.x) * (v1.y - v2.y) - (v1.x - v2.x)
                * (u1.y - u2.y));
    }

    public static boolean intersect_ex(Point u1, Point u2, Point v1, Point v2) {
        return opposite_side(u1, u2, v1, v2) && opposite_side(v1, v2, u1, u2);
    }

    public static boolean dot_online_in(Point p, Point l1, Point l2) {
        return zero(xmult(p, l1, l2)) && (l1.x - p.x) * (l2.x - p.x) < EPS
                && (l1.y - p.y) * (l2.y - p.y) < EPS;
    }

    public static boolean same_side(Point p1, Point p2, Point l1, Point l2) {
        return xmult(l1, p1, l2) * xmult(l1, p2, l2) > EPS;
    }

    public static boolean intersect_in(Point u1, Point u2, Point v1, Point v2) {
        if (!dots_inline(u1, u2, v1) || !dots_inline(u1, u2, v2))
            return !same_side(u1, u2, v1, v2) && !same_side(v1, v2, u1, u2);
        return dot_online_in(u1, v1, v2) || dot_online_in(u2, v1, v2)
                || dot_online_in(v1, u1, u2) || dot_online_in(v2, u1, u2);
    }

    public static boolean dots_inline(Point p1, Point p2, Point p3) {
        return zero(xmult(p1, p2, p3));
    }

    public static boolean dot_online_ex(Point p, Point l1, Point l2) {
        return dot_online_in(p, l1, l2)
                && (!zero(p.x - l1.x) || !zero(p.y - l1.y))
                && (!zero(p.x - l2.x) || !zero(p.y - l2.y));
    }

    public static boolean opposite_side(Point p1, Point p2, Point l1, Point l2) {
        return xmult(l1, p1, l2) * xmult(l1, p2, l2) < -EPS;
    }

    public static double distance(Point p1, Point p2) {
        return Math.sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y)
                * (p1.y - p2.y));
    }

    public static double xmult(Point p1, Point p2, Point p0) {
        return (p1.x - p0.x) * (p2.y - p0.y) - (p2.x - p0.x) * (p1.y - p0.y);
    }

    public static boolean zero(double x) {
        return (((x) > 0 ? (x) : -(x)) < EPS);
    }

    public static Point intersection(Point u1, Point u2, Point v1, Point v2) {
        Point ret = new Point(u1);
        double t = ((u1.x - v1.x) * (v1.y - v2.y) - (u1.y - v1.y)
                * (v1.x - v2.x))
                / ((u1.x - u2.x) * (v1.y - v2.y) - (u1.y - u2.y)
                        * (v1.x - v2.x));
        ret.x += (u2.x - u1.x) * t;
        ret.y += (u2.y - u1.y) * t;
        return ret;
    }
}