Making Friends
면접 대비시간 제한3초메모리 제한1024 MB
소들이 하루에 한 마리씩 떠나고, 떠날 때 남아 있는 친구들끼리 모두 친구가 된다. 새로 생기는 친구 관계의 총 개수를 센다.
문제
There are initially () pairs of friends among FJ's () cows labeled . The cows are leaving the farm for vacation one by one. On day , the -th cow leaves the farm, and all pairs of the -th cow's friends still present on the farm become friends. How many new friendships are formed in total?
입력
The first line contains and .
The next lines contain two integers and denoting that cows and are friends (, ). No unordered pair of cows appears more than once.
출력
One line containing the total number of new friendships formed. Do not include pairs of cows that were already friends at the beginning.
힌트
On day , three new friendships are formed: , , and .
On day , two new friendships are formed: and .