406899: GYM102606 F Find / -type f -or -type d

Memory Limit:1024 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

F. Find / -type f -or -type dtime limit per test1 secondmemory limit per test1024 megabytesinputstandard inputoutputstandard output

Cuber QQ wants to know the number of files with extension .eoj in his computer. This can be easily done with a command find / -type f | grep '$$$\backslash$$$.eoj$' | wc -l. However, Cuber QQ is a grep-hater, who would rather write his own program than using grep. So he decides to take a detour: what if the command starts with something else? Is it still possible to recover the results?

If you are not familiar with command usages in Linux, all you need to know is that ls and find are two easy-to-use commands to inspect files and subdirectories a directory contains. For example, when you are trying to get a list of everything in your computer, you might try to use: find / -type f -or -type d, which will give you a list like:

To make the problem even more interesting, Cuber QQ adds another shuf after find, so that the list is shuffled into a random order and his secrets will stay covered. Cuber QQ is wondering whether it's possible to write a program cuber-qq-grep that filters out all the files with extension .eoj from the given shuffled list, which is his initial intention. Still, instead of giving the filtered list directly, Cuber QQ wants to know the length of this list, i.e., the number of files found. In other words, the following two commands will be almost equivalent:

  • find / -type f | grep '$$$\backslash$$$.eoj$' | wc -l
  • find / -type f -or -type d | shuf | cuber-qq-grep

Well, there can be some subtle differences in input/output formats, but that's not essential.

One more thing, on your file system, directory is only a logical concept. This means, a directory is created only when there is a file which relies on this directory is created and a directory cannot exist without files.

TL;DR, given the randomly shuffled list of all directories and files on a computer, count the number of files that ends with .eoj.

Input

The input starts with a line of one number $$$n$$$ ($$$1 \le n \le 10^5$$$), which is the length of the following list.

In the following $$$n$$$ lines, each line contains one string, which is an absolute path to a file or a directory. The path starts with /, and is composed of multiple tokens (file names and directory names) concatenated with /. The tokens always start with a lowercase letter, followed by no more than $$$9$$$ lowercase letters or dots. The root folder alone will not be included in this list.

It is guaranteed that the total length of $$$n$$$ lines will be no longer than $$$10^6$$$.

Output

Output the number of files satisfying the above-mentioned condition, in one line.

ExamplesInput
3
/secret/eoj
/secret
/secret.eoj
Output
1
Input
8
/i/am/an/ecnu/student
/i/am/an/ecnu
/i
/i/am/a
/i/am/an/idiot
/i/am/an
/i/am/a/genious
/i/am
Output
0
Input
2
/cuber.eoj/qq.eoj
/cuber.eoj
Output
1

加入题单

算法标签: