In some black-black wood at the black-black cemetery there was a golden gravestone. This gravestone was guarded by two black-black dogs. Each dog sits enchained near a black-black pole and nearby in the wood there is a black-black guard’s house. Every morning the guard leaves the house to bring the dogs plates with food. He places the plates so that the dogs may eat remaining enchained to their poles.
Compute the shortest way that the guard is to walk in order to feed both dogs (the guard may easily carry food to both dogs at the same time and may feed them in an arbitrary order).
The first line contains three numbers: the distance in meters from the guard’s house to the first pole R1, from the guard’s house to the second pole R2 and the distance between the poles R3. The second line consists of one integer which is the length of each dog’s chain R4 (the chains of the dogs are identical). The numbers Ri (i = 1, 2, 3) satisfy the restriction 0 ≤ Ri ≤ 10000; 1 ≤ R4 ≤ 10000.
Output the single number which is the length of the shortest guard’s way in meters within three digits after a decimal point.
1000 2000 1000
Problem Author: Alexander Petrov (prepared by Alexander Mironenko)
Problem Source: Open collegiate programming contest for student teams, Ural State University, March 15, 2003