All problems

Problem 801

Manhattan Distance Between Two Points

Easy · 10 pts · Math, Basics, Geometry

Problem

The Manhattan distance between points (X1, Y1) and (X2, Y2) is |X1 - X2| + |Y1 - Y2|: the distance you would walk on a city grid where you can only move along the streets (horizontally or vertically). Compute it for the two given points. The result can reach 4 × 10^9, so use a 64-bit integer.

Input

A single line with four integers X1, Y1, X2 and Y2.

Output

Print the Manhattan distance.

Constraints

-10^9 <= coordinates <= 10^9

Example input

1 2 4 -2

Example output

7

Explanation

From (1, 2) to (4, -2) you move 3 steps in X and 4 steps in Y, so the distance is 3 + 4 = 7.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Quadrant of a Point Next: Sum of Multiples of 3 or 5