#C4062. Total Production Calculation After Machine Shutdown

    ID: 47559 Type: Default 1000ms 256MiB

Total Production Calculation After Machine Shutdown

Total Production Calculation After Machine Shutdown

A manufacturing company operates two types of machines, type X and type Y. Each machine of type X produces A units per hour, and each machine of type Y produces B units per hour. Initially, there are M machines of type X and N machines of type Y. Due to operational constraints, the company must shut down exactly one machine. The shutdown is specified by a character: 'X' if a type X machine is shut down or 'Y' if a type Y machine is shut down.

After shutting down the specified machine, the total production is computed as follows:

\[ P = A \times (M - \delta_X) + B \times (N - \delta_Y), \]

where \( \delta_X = 1 \) if the shutdown type is 'X' and 0 otherwise, and \( \delta_Y = 1 \) if the shutdown type is 'Y' and 0 otherwise.

Your task is to calculate the total production of the company after shutting down the specified machine.

inputFormat

The input consists of a single line containing five items separated by spaces:

  • A: An integer representing the units produced per type X machine per hour.
  • B: An integer representing the units produced per type Y machine per hour.
  • M: An integer representing the number of type X machines.
  • N: An integer representing the number of type Y machines.
  • shutdown: A character (either X or Y) indicating the type of machine to shut down.

outputFormat

Output a single integer: the total production of the company after the specified machine is shut down.

## sample
5 7 3 4 X
38