Under construction

Still being built. Things may change

Cake Promise

Time limit2sMemory limit2048 MB

Summary
Given each team's per-problem solve times (X for unsolved), count the teams that solved more problems than Professor Wright, or the same number with an equal or lower total time.
Level

Easy2 of 10

Topics
Implementation, Array
Solved
No attempts yet

Problem

Today is the big day. Professor P. Wright is organizing a programming contest. All of his students are participating, because he has promised to bake a cake for every team that can beat him in the contest.1 After the contest ends, Professor Wright receives a raw copy of the scoreboard, in which the teams are out of order. He is short on time, since besides baking he also has some exams to grade. He needs a program that calculates how many teams beat him in the contest.

The contest has a given number of problems, which the teams must solve as fast as possible. One team beats another if the first team has solved strictly more problems. If two teams have solved the same number of problems, the team with the lower total time beats the other. Professor Wright also bakes a cake for every team that solved the same number of problems and had the same total time as he did.

1 All characters and events in this problem statement are fictional. Any resemblance to actual lecturers is purely coincidental.

Input

The first line contains two integers tt and pp (2≤t,p≤10002\leq t, p\leq 1000), the number of teams and the number of programming problems. Professor Wright counts as one of the teams. Then tt lines follow, each containing pp values with the results of one team. The first of these lines gives the results of Professor Wright. Each value is either "X", meaning the team did not solve that problem, or an integer rr (1≤r≤1061\leq r\leq 10^6), the number of minutes the team needed to solve it.

Output

Output the number of teams for which Professor Wright needs to bake a cake.

Examples2

  1. Example 1

    Input
    5 5
    40 X 10 30 20
    X X 20 50 40
    50 40 20 30 10
    X X 30 X 50
    X 30 5 40 20
    
    Expected output
    2
    
  2. Example 2

    Input
    4 4
    4 5 6 X
    4 5 X 5
    4 X 5 6
    X 4 5 7
    
    Expected output
    2