#!/bin/python3

import math
import os
import random
import re
import sys

#
# Complete the 'workbook' function below.
#
# The function is expected to return an INTEGER.
# The function accepts following parameters:
#  1. INTEGER n
#  2. INTEGER k
#  3. INTEGER_ARRAY arr
#

def workbook(n, k, arr):
    # Write your code here
    listOfNums = []
    prob = 0 
    indeks = 0 
    num = 0 
    
    for i in arr:
        if i < k : 
            listOfNums.append(i)
            indeks+=1
            if i >= indeks:
                num+=1
        else:
            if i % k == 0 : 
                for j in range(i//k):
                    
                    listOfNums.append(k)
                    indeks+=1
                    if indeks>prob and indeks<=prob+k:
                        print(indeks,prob,prob+k)
                        num+=1
                        
                    prob+=k
                prob=0
            else:
                for j in range(i//k):
                    listOfNums.append(k)
                    indeks+=1
                    if indeks>prob and indeks<=prob+k:
                        num+=1
                    prob+=k
                    
                listOfNums.append(i%k)
                indeks+=1
                print(prob+(i%k))
                if indeks>prob and indeks<=(prob+(i%k)):
                    
                    num+=1
                    
                prob = 0
        print(listOfNums)
        print(num)
        print(indeks)
         
    return num
                
                
            

if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    first_multiple_input = input().rstrip().split()

    n = int(first_multiple_input[0])

    k = int(first_multiple_input[1])

    arr = list(map(int, input().rstrip().split()))

    result = workbook(n, k, arr)

    fptr.write(str(result) + '\n')

    fptr.close()
