#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef complex<LD> CMP;

class TheJediTest { public:
	int minimumSupervisors(vector <int> students, int K)
	{
		return rec(0, 0, students, K);
	}

	int rec(int i, int dsi, const vector<int>& s, int K)
	{
		if(i+1 == s.size())
			return (s[i]+dsi+K-1) / K;

		int maxMoveOut = (dsi<0 ? s[i]+dsi : s[i]);
		int maxMoveIn  = s[i+1];
		int X = s[i] + dsi;

		int best = 0x7fffffff;

		int Xout = X/K*K;
		if(X-Xout > maxMoveOut)
			Xout = X-maxMoveOut;
		best = min(best, (Xout+K-1)/K + rec(i+1, X-Xout, s, K));

		int Xin = (X/K+1)*K;
		if(Xin-X > maxMoveIn)
			Xin = X+maxMoveIn;
		best = min(best, (Xin+K-1)/K + rec(i+1, X-Xin, s, K));
		return best;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const int& Expected, const int& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, TheJediTest().minimumSupervisors(students, K));}
int main(){

CASE(0)
	int students_[] = {3, 6, 3};
	  vector <int> students(students_, students_+sizeof(students_)/sizeof(*students_)); 
	int K = 4; 
	int _ = 3; 
END
CASE(1)
	int students_[] = {1, 1, 1, 1};
	  vector <int> students(students_, students_+sizeof(students_)/sizeof(*students_)); 
	int K = 4; 
	int _ = 2; 
END
CASE(2)
	int students_[] = {0, 0, 0, 0};
	  vector <int> students(students_, students_+sizeof(students_)/sizeof(*students_)); 
	int K = 12345; 
	int _ = 0; 
END
CASE(3)
	int students_[] = {15, 0, 13, 4, 29, 6, 2};
	  vector <int> students(students_, students_+sizeof(students_)/sizeof(*students_)); 
	int K = 7; 
	int _ = 10; 
END
CASE(4)
	int students_[] = {1284912, 1009228, 9289247, 2157, 2518, 52781, 2, 2818, 68};
	  vector <int> students(students_, students_+sizeof(students_)/sizeof(*students_)); 
	int K = 114; 
	int _ = 102138; 
END
CASE(5)
int students_[] = {4,0,5};
	  vector <int> students(students_, students_+sizeof(students_)/sizeof(*students_)); 
	int K = 3; 
	int _ = 3; 
END
/*
CASE(6)
	int students_[] = ;
	  vector <int> students(students_, students_+sizeof(students_)/sizeof(*students_)); 
	int K = ; 
	int _ = ; 
END
*/
}
// END CUT HERE
