import itertools
import numpy as np
import sys

def resolve():
	input = sys.stdin.readline

	N, L = list(map(int,input().strip().split()))
	alist = list(map(int,input().strip().split()))

	# print(alist)

	count = N 	# 1 factor array must satisfy the condition
	for x in itertools.combinations(range(N), 2):
		i, j = x[0], x[1]

	# for x in range(1):
		# i, j = 0,8

		target_list = alist[i:j+1]
		maximum = max(target_list)
		level_count = np.zeros(maximum, 'int64')
		pre_num = maximum
		condition = True

		for index in range(len(target_list)):
			target = target_list[index]
			level_count[target-1] = level_count[target-1]+1

			if target>pre_num:
				for ti in range(target-1):
					if level_count[ti]!=0:
						moveup = int(level_count[ti]/L)
						if moveup==0:
							condition = False
							break
						else:
							level_count[ti+1] = level_count[ti+1]+moveup
							level_count[ti] = 0

			if condition==False:
				break
			else:
				pre_num = target

		if condition==True:
			for ti in range(maximum-1):
				if level_count[ti]!=0:
					moveup = int(level_count[ti]/L)
					if moveup==0:
						condition = False
						break
					else:
						level_count[ti+1] = level_count[ti+1]+moveup
						level_count[ti] = 0

			if (condition==True) and (level_count[-1]>=L):
				count = count+1
				# print(i,j)

	print(count)

if __name__ == "__main__":
    resolve()
