Under construction

Still being built. Things may change

Manhattan Distance on a Four-Row Number Board

Interview

Time limit2sMemory limit128 MB

Summary
Given two numbers placed column by column in a 4-row grid, compute the Manhattan distance between their cell positions.
Level

Easy2 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

There is a number board with 4 rows. Starting from 1, numbers are written down each column from top to bottom, then continue in the next column. Therefore 1, 2, 3, and 4 are in the first column, while 5, 6, 7, and 8 are in the second column.

Given two natural numbers A and B, find the Manhattan distance between their cells on the board. The Manhattan distance is the sum of the horizontal distance and the vertical distance.

Input

The first line contains two natural numbers A and B separated by a space. Each number is at most 10,000,000.

Output

Print the Manhattan distance between the cells containing the two numbers.

Examples1

  1. Example 1

    Input
    11 33
    
    Expected output
    8