문제
Farmer John has lost his favorite cow bell, and Bessie the cow has agreed to help him find it! They both fan out and search the farm along different paths, but stay in contact via radio so they can keep in touch with each-other. Unfortunately, the batteries in their radios are running low, so they want to plan their movements so as to conserve power, by trying to stay always within a short distance apart.
Farmer John starts at location (
Please help FJ and Bessie plan a joint movement strategy that will minimize the total amount of energy consumed up to and including the final step where both of them first reach the final locations on their respective paths.
Problem credits: Brian Dean
입력
The first line of input contains
It is guranteed that Farmer John and Bessie's coordinates are always in the range (
출력
Output a single integer specifying the minimum energy FJ and Bessie can use during their travels.
예제1
2 7
3 0
5 0
NN
NWWWWWN
28