l,s=gets.split l=l.to_i a=[390,429,468,507,546] l-=1 if s!="Beat" puts a[l]