#C7912. Total Farm Animals
Total Farm Animals
Total Farm Animals
You are given the total number of legs on a farm and the number of cows. Each cow has 4 legs and each chicken has 2 legs. Using the formula [ \text{chickens} = \frac{\text{legs} - 4 \times \text{cows}}{2} ] compute the total number of animals on the farm, which is the sum of the number of cows and chickens. Note that the input values will guarantee that the number of chickens computed is an integer.
inputFormat
The input consists of two space-separated integers provided via standard input (stdin): the first integer represents the total number of legs on the farm, and the second integer represents the number of cows.
outputFormat
Output a single integer, the total number of animals on the farm, to standard output (stdout).## sample
20 3
7