Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register
Language:
Distance to the Prey
Time Limit: 1000MSMemory Limit: 131072K
Total Submissions: 251Accepted: 35

Description

Zhizhu is a intelligent spider. His mean of weaving is different from everyone:

His first web was called S0. Then he connected five S0 into a bigger web S1. In the same way he got S2, S3, etc, as the figure above shows. Finally he finished his work S10000!

Today a insect touches the web and gets stuck. The insect is located at (a,b), and Zhizhu is at (c,d). The coordinates are all integers. He wants to know how far he needs to walk in order to reach his prey. Of course, he has to walk along the web S10000.

Input

There are multiple test cases. Each case contains one line consisting of 4 integers a, b, c, d (0 ≤ a,b,c,d ≤ 109).

Output

For each test case you need to print one number, the distance Zhizhu has to walk.

Sample Input

5 3 6 4

Sample Output

2

Hint

The figure above is one part of S10000. Zhi zhu can walk from (6,4) to (6,3), then (5,3).

Source

[Submit]   [Go Back]   [Status]   [Discuss]

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator