This page is still under construction.

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

Elevators

Interview

Time limit1sMemory limit1024 MB

Summary
Given a zoning district and a floor count between 1 and 20, look up the required number of elevators from a fixed table.
Level

Easy2 of 10

Topics
Implementation, Brute force, Array
Solved
No attempts yet

Problem

Whenever a new building is built, it must comply with all the relevant building regulations. In particular, there are rules governing the number of elevators a building must have depending on its number of floors and zoning district.

If a building has only one floor, it doesn't need any elevators; otherwise, it needs more elevators the more floors it has, and the exact number depends on its zoning district. The following tables describe the number of elevators necessary for a building in each of the residential, commercial, and industrial zoning districts.

ResidentialCommercialIndustrial
FloorsElevatorsFloorsElevatorsFloorsElevators
110011001100
2−52-5112−72-7112−42-411
6−106-10228−148-14225−85-822
11−1511-153315−2015-20339−129-1233
16−2016-2044  13−1613-1644
    17−2017-2055

Table 1: Elevator requirements by zone

You are given the zoning district of a new building and how many floors it has. How many elevators does it need?

Input

The only line of input contains a string representing the zoning district of the building ("residential", "commercial", or "industrial"), followed by a space and an integer NN (1≤N≤201 \leq N \leq 20), the number of floors the building has.

Output

Output a single integer: the number of elevators the building must have.

Examples2

  1. Example 1

    Input
    residential 6
    
    Expected output
    2
    
  2. Example 2

    Input
    industrial 20
    
    Expected output
    5