#!/usr/bin/python

orientation = raw_input("h or w: ");

if orientation != "h" and orientation != "w":
  print "Unrecognized input choose h or w";
  exit(1);

origin_width = float(raw_input("Original Width: "));
origin_height = float(raw_input("Original Height: "));
if(orientation == "h"):
  new_height = float(raw_input("New Height: "));
  new_width = (origin_width / origin_height) * new_height;
  print "New Width: " + str(new_width);
else:
  new_width = float(raw_input("New Width: "));
  new_height = (origin_height / origin_width) * new_width;
  print "New Height: " + str(new_height);