An infinite beehive extends as in the figure. Two cells are adjacent exactly when they share a side. A path of length k from cell c0 to cell ck is a sequence of cells c0,c1,…,ck such that ci and ci+1 are adjacent for every i with 0≤i<k. The distance between two cells is the length of a shortest path from one to the other.

Each cell of the beehive carries one positive integer index, as the figure shows. A cell farther from cell 1 gets a larger index, and among the cells at the same distance from cell 1 the index grows from left to right. Some cells at the same distance share a column. In the leftmost such column the lower cell comes first, and in the rightmost such column the upper cell comes first. The cells at one distance are therefore numbered by starting at the bottom left cell, climbing that column, crossing the top, and coming down to the bottom right cell. Every positive integer is the index of exactly one cell.
Given the indices of two cells, compute the distance between them.