/*
Guide to Manhattan Street Numbers
(from back of Panchito's business card, 105 MacDougal Street)

Cancel last figure of house number.
Divide remainder by two and add the key number below.
Result is approximately nearest street.

  3	First Avenue
  3	Second Avenue
 10	Third Avenue
  8	Fourth Avenue
 13	  1 to  200 Fifth Avenue
 16	201 to  400 Fifth Avenue
 18	401 to  600 Fifth Avenue
 20	601 to  775 Fifth Avenue
-18	776 to 1286 Fifth Avenue and don't divide by 2
-12	Sixth Avenue
 12	1 to 1800 Seventh Avenue
 20	above 1800 Seventh Avenue
  9	Eighth Avenue
 13	Ninth Avenue
 13	Tenth Avenue
 15	Eleventh Avenue
 59	Amsterdam Avenue
 59	Columbus Avenue
 22	Lexington Avenue
 27	Madison Avenue
 35	Park Avenue
 59	West End Avenue
 60	Central Park West and don't divide by 2
 73	1 to 567 Riverside Drive and don't divide by 2
 78	above 567 Riverside Drive and don't divide by 2
	1 to 754 Broadway -- below Eighth Street
-29	754 to 858 Broadway
-25	858 to 958 Broadway
-31	above 1000 Broadway

Example: 350 Park Avenue.
Cancel last figure (0), divide by 2, and add key number (34).
Answer: 51st Street.

Street numbers commence as follows:

East Side:
  1 at 5th Avenue
101 at Park or 4th Avenue
201 at 3rd Avenue
301 at 2nd Avenue
401 at 1st Avenue
501 at York Avenue or Avenue A
601 at Avenue B

West Side:
  1 at 5th Avenue
101 at 6th Avenue
201 at 7th Avenue
301 at 8th Avenue
401 at 9th Avenue
501 at 10th Avenue
601 at 11th Avenue
*/

//The following 3 lines are needed to get a number from the keyboard.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Manhattan {
	public static void main(String[] args) {
		final int Amsterdam = 12;
		final int Columbus = 13;
		final int Lexington = 14;
		final int Madison = 15;
		final int Park = 16;
		final int WestEnd = 17;
		final int CentralParkWest = 18;
		final int RiversideDrive = 19;
		final int Broadway = 20;

		final String[] name = {
			null,	//array subscripts always start at zero
  			"First Avenue",
			"Second Avenue",
			"Third Avenue",
			"Fourth Avenue",
			"Fifth Avenue",
			"Sixth Avenue",
			"Seventh Avenue",
			"Eighth Avenue",
			"Ninth Avenue",
			"Tenth Avenue",
			"Eleventh Avenue",
			"Amsterdam Avenue",
			"Columbus Avenue",
			"Lexington Avenue",
			"Madison Avenue",
			"Park Avenue",
			"West End Avenue",
			"Central Park West",
			"Riverside Drive",
			"Broadway"
		};

		final int[] key = {
			  0,	//array subscripts always start at zero
  			  3,	//First Avenue starts at Houston Street
			  3,	//Second Avenue starts at Houston Street
			 10,	//Third Avenue starts at Eighth Street
			  8,	//Fourth Avenue starts at Eighth Street
			  0,	//Fifth Avenue
			-12,	//Sixth Avenue
			  0,	//Seventh Avenue
			  9,	//Eighth Avenue starts at 12th Street
			 13,	//Ninth Avenue (becomes Columbus at 59th St.)
			 13,	//Tenth Avenue (becomes Amsterdam at 59th St.)
			 15,	//Eleventh Avenue starts at 14th Street
			 59,	//Amsterdam Avenue starts at 59th Street
			 59,	//Columbus Avenue starts at 59th Street
			 22,	//Lexington Avenue starts at 21st Street
			 27,	//Madison Avenue starts at 23rd Street
			 35,	//Park Avenue starts at 32nd Street
			 59,	//West End Avenue starts at 59th Street
			 60,	//Central Park West starts at 59th Street
			  0,	//Riverside Drive
			  0,	//Broadway
		};

		System.out.print("Avenue number (1 to 11 inclusive), ");
		System.out.println("or one of the following:");
		for (int i = Amsterdam; i <= Broadway; ++i) {
			//tab character
			System.out.println("\t" + i + " " + name[i]);
		}
		System.out.println();

		System.out.print("Avenue: ");
		final int avenue = getInt();
		if (avenue <= 0 || avenue >= key.length) {
			System.err.println("Must be in range 1 to "
				+ (key.length - 1) + " inclusive.");
			System.exit(1);
		}

		System.out.print("Building number: ");
		final int building = getInt();
		if (building <= 0) {
			System.err.println("Can't be negative.");
			System.exit(1);
		}

		int divisor = 20;
		int k = key[avenue];

		switch (avenue) {

		case 5:
			if (building <= 200) {
				k = 13;
			} else if (building <= 400) {
				k = 16;
			} else if (building <= 600) {
				k = 18;
			} else if (building <= 775) {
				k = 20;
			} else if (building <= 1286) {
				k = -18;
				divisor = 10;
			}
			break;

		case 7:
			if (building <= 1800) {
				k = 12;
			} else {
				k = 20;
			}
			break;

		case CentralParkWest:
			divisor = 10;
			break;

		case RiversideDrive:
			divisor = 10;
			if (building <= 567) {
				k = 73;
			} else {
				k = 78;
			}
			break;

		case Broadway:
			if (building <= 754) {
				divisor = 100;	//below Eighth Street
				k = 0;
			} else if (building <= 858) {
				k = -29;
			} else if (building <= 958) {
				k = -25;
			} else {
				k = -31;
			}
			break;
		}

		final int street = building / divisor + k;

		System.out.println(building + " " + name[avenue] + " is at "
			+ street + " Street.");
	}

	//The following 16 lines needed to get number from keyboard.
	private static BufferedReader reader =
		new BufferedReader(new InputStreamReader(System.in));
	private static int getInt() {
		try {
			return Integer.parseInt(reader.readLine());
		}
		catch (IOException e) {
			System.err.println("Couldn't receive input: "
				+ e.getMessage());
		}
		catch (NumberFormatException e) {
			System.err.println(e.getMessage()
				+ ", characters not a number.");
		}
		return 0;
	}
}