-->
当前位置:首页 > 题库

PROGRAMMING:Little t's doubts

Luz5年前 (2021-05-10)题库446
Small t is a very boring person, nothing like eavesdropping on other people's chat. One day when he was queuing up in the canteen, he heard the freshmen chatting, so he also came over. I heard the following conversation:
Xiao L: Xiao Z and I are classmates.
Z: I'm a classmate with H.
Small h: I and small R are classmates.
Small B: I and small a are classmates.
Z: I'm a classmate with Z.
Small t want to know, chat of these students at most from several different classes, can you help him.
###Input format:
The first line contains two integers $$n (1 / Leq n / Leq 100000) $, $$m (1 / Leq M / Leq 50000) $. The number of students and the number of sentences in the chat.
Next, $$M $$lines, each line gives a statement in the following form:
$$xxx\ :\ wo\ he\ yyy\ shi\ tong\ xue$$
Where, $$XXX $$and $$YYY $$are strings no longer than $$10 $, representing a person's name, and $$XXX $$and $$YYY $$may be the same.
###Output format:
Output an integer to indicate how many different classes these students come from at most.
###Example 1
####Input sample
```in
6 5
L : wo he Z shi tong xue
Z : wo he H shi tong xue
H : wo he R shi tong xue
B : wo he A shi tong xue
Z : wo he Z shi tong xue
```
####Output sample
```out
two
```
###Example 2
####Input sample
```in
6 1
L : wo he L shi tong xue
```
####Output sample
```out
six
```






answer:If there is no answer, please comment