Under construction

Still being built. Things may change

Road to SPC

Interview

Time limit1sMemory limit1024 MB

Summary
Given home, venue, and one blocked point, find the fewest turns in an axis-parallel walk from home to the venue.
Level

Easy3 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

SPC (Sogang Programming Contest) is a programming festival that any student of Sogang University can join. Seungho leaves home today to go to the SPC venue.

The SPC venue and Seungho's home are on a two-dimensional coordinate plane. Seungho's home is at (Sx,Sy)(S_x, S_y), and the SPC venue is at (Ex,Ey)(E_x, E_y). A fierce Geunsu is at (Px,Py)(P_x, P_y), so Seungho cannot pass through that point. The positions of Seungho's home, the SPC venue, and Geunsu are all different.

Seungho can only walk straight in a direction parallel to the xx-axis or the yy-axis. A turn happens when the new direction differs from the previous one. When Seungho leaves home, he can choose any direction to start, and choosing the starting direction is not counted as a turn. Seungho gets dizzy easily, so he wants to reach the SPC venue from home with as few turns as possible. Find the minimum number of turns Seungho needs.

Input

The first line contains two integers SxS_x and SyS_y, the position of Seungho's home. (−109≤Sx,Sy≤109)(-10^9 \le S_x, S_y \le 10^9)

The second line contains two integers ExE_x and EyE_y, the position of the SPC venue. (−109≤Ex,Ey≤109)(-10^9 \le E_x, E_y \le 10^9)

The third line contains two integers PxP_x and PyP_y, the position of Geunsu. (−109≤Px,Py≤109)(-10^9 \le P_x, P_y \le 10^9)

Output

Print the minimum number of turns Seungho needs.

Hint

Seungho does not have to take the shortest path to reach the SPC venue.

Examples2

  1. Example 1

    Input
    0 0
    5 5
    3 0
    
    Expected output
    1
    
  2. Example 2

    Input
    0 0
    5 0
    3 0
    
    Expected output
    2