Yumi

Interview

Time limit1sMemory limit256 MB

Summary
Given Yumi's position and three fixed people on a plane, find the shortest travel distance for Yumi to visit all three people.
Level

Easy3 of 10

Topics
Brute force, Geometry, Implementation
Solved
No attempts yet

Problem

Yumi, a cat who loves to be held, and three people are on a two-dimensional coordinate plane. A point on the plane is written as (x,y)(x, y). Yumi wants to be held by all three people. To be held by a person, Yumi must move to the position where that person is. People do not move. Since moving is a hassle, Yumi wants to reach the three people by the shortest route.

For example, if Yumi is at (0,0)(0, 0) and the three people are at (1,0)(1, 0), (2,0)(2, 0), and (4,0)(4, 0), moving in the order (0,0)→(1,0)→(2,0)→(4,0)(0, 0) \to (1, 0) \to (2, 0) \to (4, 0) is the shortest route, and its distance is 1+1+2=41 + 1 + 2 = 4.

Given the positions of Yumi and the three people, find the shortest distance for Yumi to be held by all three.

Input

The first line gives Yumi's position, and the next three lines give the positions of the people, one per line. Each position is given as x-coordinate followed by y-coordinate, separated by a space. (−10≤x,y≤10)(-10 \le x, y \le 10)

No two people share the same position, and Yumi's position never coincides with a person's position.

Output

Print the shortest distance Yumi travels on the first line. Discard any fractional part and print only the integer part.

Examples1

  1. Example 1

    Input
    0 0
    1 0
    2 0
    4 0
    
    Expected output
    4