#C8983. Most Popular Dish

    ID: 53025 Type: Default 1000ms 256MiB

Most Popular Dish

You are given n dishes and m guests. Each dish is evaluated by the guests with opinions represented by a string of length m. Each character in the string can be:

  • L meaning the guest likes the dish
  • D meaning the guest dislikes the dish
  • N meaning the guest is neutral

The task is to determine the most popular dish based on the following criteria:

  • The dish with the maximum number of likes ( \(L\) counts).
  • If there is a tie in the number of likes, choose the dish with the fewer number of dislikes (\(D\) counts).

Dishes are numbered from 1 to \(n\). Print the 1-based index of the most popular dish.

inputFormat

The input is read from stdin and has the following format:

n m
s1
s2
...
sn

Here, n is the number of dishes and m is the number of guests. Each of the following n lines contains a string si of length m representing the opinions of the guests on the ith dish.

outputFormat

Output a single integer to stdout – the 1-based index of the most popular dish.

## sample
3 4
LNDN
NDLL
DDDN
2