Fair Photography

No attempts yetTime limit1sMemory limit128 MB

Problem

NN cows stand along a fence at distinct positions. Each is white (W) or spotted (S). You may paint some white cows spotted so an interval photo can have equal counts.

Photo size is max position minus min position among included cows. Find the maximum fair photo size.

Input

Line 1: NN.

Next NN lines: position xix_i and W or S.

Output

Maximum photo size.