This page is still under construction.

Parts of this page are still being built. What you see may change.

Hard choice

Time limit1sMemory limit1024 MB

Summary
Given prepared and requested counts for chicken, beef, and pasta, count passengers whose requested meal is unavailable.
Level

Easy1 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

On long flights an airline serves hot meals. A flight attendant usually pushes a cart of meals down the aisle, and the moment the cart reaches your row you are asked: "Chicken, beef, or pasta?" You know the options, but you have only a few seconds to pick, and you cannot tell what your choice looks like because your neighbor has not opened the wrap yet.

The attendant on this flight changed the order of things. First she asks every passenger which meal they want, and then she checks whether the number of meals prepared for each option is enough.

For example, suppose the prepared counts for chicken, beef and pasta are 80, 20 and 40, while the counts requested by passengers are 45, 23 and 48. Eleven passengers then do not get the meal they chose, because three passengers who wanted beef and eight who wanted pasta cannot be served.

Given the prepared count and the requested count for each option, find how many passengers do not get the meal they chose. A passenger is satisfied only by the option they picked, so being handed a leftover meal of another type does not count.

Input

The first line contains three integers CaC_a, BaB_a and PaP_a (0≤Ca,Ba,Pa≤1000 \le C_a, B_a, P_a \le 100), the number of meals prepared for chicken, beef and pasta.

The second line contains three integers CrC_r, BrB_r and PrP_r (0≤Cr,Br,Pr≤1000 \le C_r, B_r, P_r \le 100), the number of passengers who requested chicken, beef and pasta.

Output

Print one line with a single integer, the number of passengers who do not get the meal they chose.

Examples3

  1. Example 1

    Input
    80 20 40
    45 23 48
    
    Expected output
    11
    
  2. Example 2

    Input
    0 0 0
    100 100 100
    
    Expected output
    300
    
  3. Example 3

    Input
    41 42 43
    41 42 43
    
    Expected output
    0