Under construction

Still being built. Things may change

I Hate Raisins

Time limit1sMemory limit1024 MB

Summary
Given an X by Y by Z cake with one hidden unit raisin, find the fewest axis-parallel cuts that pinpoint the raisin's cell in the worst case.
Level

Medium6 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

A cake shaped like a rectangular box has edge lengths XX, YY, and ZZ. Somewhere inside the cake is one raisin of unit size (1×1×11 \times 1 \times 1). Treat the cake as a grid of unit-size cells. The raisin occupies exactly one of those cells. You are allergic to raisins, so before eating the cake, you decide to cut it and pinpoint the raisin's position. The cutting rules are as follows:

  • A cut must be a plane parallel to the xx, yy, or zz axis, and it cuts through the entire plane.
  • Rearranging the pieces after a cut is forbidden.
  • A cut is allowed only if the result can be divided into unit-size pieces.

After cutting the cake zero or more times in this way, you can observe all surfaces of the resulting pieces. A cell is confirmed as the raisin cell even if only one of its faces is exposed.

You want to keep the cake as intact as possible, so you want to minimize the number of cuts. Using the best strategy, find the minimum number of cuts that pinpoints the raisin's position even in the worst case.

Input

The first line contains three integers XX, YY, and ZZ, separated by spaces. (1≤X,Y,Z≤100 0001\leq X, Y, Z \leq 100\,000)

Output

On the first line, print the minimum number of cuts needed to pinpoint the raisin's position in the worst case when using the best strategy.

Examples2

  1. Example 1

    Input
    1 1 1
    
    Expected output
    0
    
  2. Example 2

    Input
    3 3 5
    
    Expected output
    1