This page is still under construction.

Parts of this page are still being built. What you see may change.

Exam Manipulation

Interview

Time limit1sMemory limit512 MB

Summary
Given n students' True/False answer strings of length k, choose an answer key to maximize the minimum score across all students.
Level

Medium5 of 10

Topics
Brute force, Bit manipulation, Implementation, Array
Solved
No attempts yet

Problem

A group of students is taking a True/False exam. Each question is worth one point. You, as their teacher, want to make your students look as good as possible, so you cheat! (I know, you would never actually do that.) To cheat, you manipulate the answer key so that the lowest score in the class is as high as possible.

What is the best possible lowest score you can achieve?

Input

The first line of input contains two integers nn (1≤n≤1,0001 \le n \le 1,000) and kk (1≤k≤101 \le k \le 10), where nn is the number of students, and kk is the number of True/False questions on the exam.

Each of the next nn lines contains a string of length kk, consisting only of upper-case ‘T’ and uppercase ‘F’. This string represents the answers that a student submitted, in the order the questions were given.

Output

Output, on a single line, the best possible lowest score in the class.

Examples2

  1. Example 1

    Input
    5 4
    TFTF
    TFFF
    TFTT
    TFFT
    TFTF
    
    Expected output
    2
    
  2. Example 2

    Input
    3 5
    TFTFT
    TFTFT
    TFTFT
    
    Expected output
    5