#1089
Unrated
MALCOLM
시간 제한
1s
메모리 제한
32MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Since teacher Herkabe has started ranking his N students, the number of friendships in his class has sharply fallen. The students near the bottom of the rankings list have become jealous of the top students, while the top students started looking down on their less successful colleagues. According to Malcolm's observations, the following rule holds: two students are friends if their ranks are close enough, more precisely, if they differ by at most K. For example, if K = 1, then only neighbouring students on the rankings list are friends. Furthermore, two students are good friends if they are friends and their names have the same length. Write a program to calculate the number of pairs of good friends in this gifted class.

입력

The first line of input contains two positive integers, N (3 ≤ N ≤ 300 000) and K (1 ≤ K ≤ N), from the problem statement. Each of the following N lines contains a single student's name. The names are given in the order they appear on the rankings list. They consist of between 2 and 20 (inclusive) uppercase English letters.

출력

The first and only line of output must contain the required number of pairs.

예제 입력 1

4 2
IVA
IVO
ANA
TOM

예제 출력 1

5

예제 입력 2

6 3
CYNTHIA
LLOYD
STEVIE
KEVIN
MALCOLM
DABNEY

예제 출력 2

2
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.