CF677D Vanya and Treasure

Description

Vanya is in the palace that can be represented as a grid $ n×m $ . Each room contains a single chest, an the room located in the $ i $ -th row and $ j $ -th columns contains the chest of type $ a_{ij} $ . Each chest of type $ x

Input Format

The first line of the input contains three integers $ n $ , $ m $ and $ p $ ( $ 1

Output Format

Print one integer — the minimum possible total distance Vanya has to walk in order to get the treasure from the chest of type $ p $ .