Problems No Larger Than the Weeds
InterviewTime limit1sMemory limit1024 MB
Count how many problems have a total character size no greater than the weed size J, where uppercase letters are 4, lowercase letters and digits are 2, and spaces are 1.
- Level
Easy2 of 10
- Topics
- Implementation, String
- Solved
- No attempts yet
Problem
Weeds grow a lot in summer.
People in Bsil Village are struggling with weeds that shot up suddenly after this summer's monsoon rains. Tasty PS problems are growing in the village fields, but the weeds hide them so they cannot be seen.
The size of a PS problem, made of English letters, spaces, and digits, is the sum of the sizes of its characters. An uppercase letter has size , a digit or lowercase letter has size , and a space has size .
Bihaengssi's field, where the problems for the Bsil Cup were to be harvested, has also been overrun by weeds. With the deadline close, Bihaengssi decided to harvest the problems that have grown bigger than the weeds before pulling the weeds. Problems that are not harvested will grow further for the next contest.
Write a program that gives Bihaengssi the number of problems that are no larger than the weeds, since there is no time to spare.
Input
The first line contains the weed size and the number of growing problems , separated by a space.
From the second line, lines follow, each containing one problem made of English letters, digits, and spaces. Each problem has length from to , and does not start or end with a space.
Output
Print the number of problems that are no larger than the weeds.