ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

1256. Cemetery Guard

Time limit: 1.0 second
Memory limit: 64 MB
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).

Input

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 ≤ 20000; 1 ≤ R4 ≤ 20000.

Output

Output the single number which is the length of the shortest guard’s way in meters within three digits after a decimal point.

Sample

inputoutput
1000 2000 1000
250
3500.000
Problem Author: Alexander Petrov (prepared by Alexander Mironenko)
Problem Source: Open collegiate programming contest for student teams, Ural State University, March 15, 2003