XYDs = readlines.drop(1).map{|l| x, y, d = l.split; [x.to_i, y.to_i, d]}

def f(t)
  xys =XYDs.map do |x, y, d|
    case d
    when 'R'; x += t
    when 'L'; x -= t
    when 'U'; y += t
    when 'D'; y -= t
    end
    [x, y]
  end
  xys.map(&:first).minmax.inject(:-).abs * xys.map(&:last).minmax.inject(:-).abs
end

xys = XYDs.group_by{|x, y, d| d}.values
vs = ->(i){xys.flat_map{|a| a.map{|b| b[i]}.minmax}.combination(2).flat_map{|a, b| d = (a - b).abs; [d, d/2.0]}}
puts ([0] + vs[0] + vs[1]).uniq.map{|t| f(t)}.min