#include <bits/stdc++.h>
using namespace std;

// a == '.', b == '#'

int main() {
    ios::sync_with_stdio(false);
    int n,m,x,y; cin >> n >> m >> x >> y; y = min(y, m);
    int a[m+1], b[m+1], a_pre[m+1], b_pre[m+1], a_res[m+1], b_res[m+1];
    for(int i = 0; i <= m; ++i) a[i] = b[i] = 0;
    char c;
    for(int i = 0; i < n; ++i) {
    	for(int j = 1; j <= m; ++j) {
    		cin >> c;
    		if (c == '.') {
    			++a[j];
    		} else {
    			++b[j];
    		}
    	}
    }

    a_pre[0] = b_pre[0] = 0;
    for(int i = 1; i <= m; ++i) a_pre[i] = a_pre[i-1] + a[i];
    for(int i = 1; i <= m; ++i) b_pre[i] = b_pre[i-1] + b[i];

    for(int i = 0; i < x; ++i) a_res[i] = b_res[i] = -1;
    for(int i = x; i <= y; ++i) {
    	a_res[i] = a_pre[i];
    	b_res[i] = b_pre[i];
    }
    for(int i = y+1; i <= m; ++i) a_res[i] = b_res[i] = INT_MAX;
    for(int i = x+1; i <= m; ++i) {
    	for(int j = i - y; j <= i - x; ++j) {
    		if (j >= x)
    			a_res[i] = min(a_res[i], b_res[j] + a_pre[i] - a_pre[j]);
    	}
    	for(int j = i - y; j <= i - x; ++j) {
    		if (j >= x)
    			b_res[i] = min(b_res[i], a_res[j] + b_pre[i] - b_pre[j]);
    	}
    }

 //    cout << endl;
 //    for(int i = 0; i <=m ; ++i) cout << a_res[i] << " ";
 //    cout << endl;
	// for(int i = 0; i <=m ; ++i) cout << b_res[i] << " ";
	//     cout << endl;
	// for(int i = 0; i <=m ; ++i) cout << a_pre[i] << " ";
	//     cout << endl;
	// for(int i = 0; i <=m ; ++i) cout << b_pre[i] << " ";
	//     cout << endl;
	// 	for(int i = 0; i <=m ; ++i) cout << a[i] << " ";
	//     cout << endl;
	// for(int i = 0; i <=m ; ++i) cout << b[i] << " ";
	//     cout << endl;

    cout << min(a_res[m], b_res[m]) << endl;
}


#include<bits/stdc++.h>
#define ll long long
#define N 10000001
#define vll vector<ll>
using namespace std;
ll n,m,x,y;
ll w[1001],b[1001];
ll Barcode(ll color,ll pos ,ll price, ll dp[][3]){
	if(pos==m){
		//cout<<price<<"  ";
		return 0;
	}
	if(dp[pos][color]!=0)
		return dp[pos][color];
	ll mx= INT_MAX;
	for(ll c=0 ;c<=1 ; c++ ){
		if(c!=color){
		for(ll i =x; i<=y && pos+i-1<m ; i++){
			if(c==1){
				ll cost =(pos==0)? w[pos+i-1] : w[pos+i-1]-w[pos-1];
				mx = min(mx, cost + Barcode(c,pos+i, price+cost,dp));
			}
			else{
				ll cost =(pos==0)? b[pos+i-1] : b[pos+i-1]-b[pos-1];
				mx = min(mx, cost + Barcode(c,pos+i, price+cost,dp));
			}
		}
		}
	}

	return dp[pos][color] = mx;
}
int main(){
	cin>>n>>m>>x>>y;
	string s[n] ;
	for(ll i=0 ; i<n ;i++){
		cin>>s[i];
	}
	for(ll i=0 ; i<m ;i++){
		ll black=0 ;
		for(ll j=0 ; j<n ; j++){
			if(s[j][i]=='#')
				black++;
		}
		b[i] = black;
		w[i] = n-black;
	}
	for(ll i=1 ; i<m ;i++){
		b[i] += b[i-1];
		w[i] += w[i-1];
	} ll dp[m+1][3];
	memset(dp,-1,sizeof(dp));
	cout<<Barcode(2,0,0,dp)<<endl;
}

/*
10 5 3 7
.####
###..
##.##
#..#.
.#...
#.##.
.##..
.#.##
#.#..
.#..#

ans == 24
*/


#include<bits/stdc++.h>
#define ll long long
#define N 10000001
#define vll vector<ll>
using namespace std;
ll n,m,x,y;
ll w[1001],b[1001];
ll Barcode(ll color,ll pos ,ll price, ll dp[][3]){
	if(pos==m){
		//cout<<price<<"  ";
		return 0;
	}
	if(dp[pos][color]!=0)
		return dp[pos][color];
	ll mx= INT_MAX;
	for(ll c=0 ;c<=1 ; c++ ){
		if(c!=color){
		for(ll i =x; i<=y && pos+i-1<m ; i++){
			if(c==1){
				ll cost =(pos==0)? w[pos+i-1] : w[pos+i-1]-w[pos-1];
				mx = min(mx, cost + Barcode(c,pos+i, price+cost,dp));
			}
			else{
				ll cost =(pos==0)? b[pos+i-1] : b[pos+i-1]-b[pos-1];
				mx = min(mx, cost + Barcode(c,pos+i, price+cost,dp));
			}
		}
		}
	}

	return dp[pos][color] = mx;
}
int main(){
	cin>>n>>m>>x>>y;
	string s[n] ;
	for(ll i=0 ; i<n ;i++){
		cin>>s[i];
	}
	for(ll i=0 ; i<m ;i++){
		ll black=0 ;
		for(ll j=0 ; j<n ; j++){
			if(s[j][i]=='#')
				black++;
		}
		b[i] = black;
		w[i] = n-black;
	}
	for(ll i=1 ; i<m ;i++){
		b[i] += b[i-1];
		w[i] += w[i-1];
	} ll dp[m+1][3]={0};
	cout<<Barcode(2,0,0,dp)<<endl;
}

/*
10 5 3 7
.####
###..
##.##
#..#.
.#...
#.##.
.##..
.#.##
#.#..
.#..#

ans == 24
*/


#include<bits/stdc++.h>
#define ll long long
#define N 10000001
#define vll vector<ll>
using namespace std;
ll n,m,x,y;
ll w[1001],b[1001];
ll Barcode(ll color,ll pos ,ll price, ll dp[][3]){
	if(pos==m){
		//cout<<price<<"  ";
		return 0;
	}
	if(dp[pos][color]!=0)
		return dp[pos][color];
	ll mx= INT_MAX;
	for(ll c=0 ;c<=1 ; c++ ){
		if(c!=color){
		for(ll i =x; i<=y && pos+i-1<m ; i++){
			if(c==1){
				ll cost =(pos==0)? w[pos+i-1] : w[pos+i-1]-w[pos-1];
				mx = min(mx, cost + Barcode(c,pos+i, price+cost,dp));
			}
			else{
				ll cost =(pos==0)? b[pos+i-1] : b[pos+i-1]-b[pos-1];
				mx = min(mx, cost + Barcode(c,pos+i, price+cost,dp));
			}
		}
		}
	}
	if(mx==INT_MAX){
		ll c= (color+1)%2;
		if(c==0)
			mx = min(mx, b[m-1]-b[pos-1]);
		else
			mx = min(mx, w[m-1]-w[pos-1]);
	}
	return dp[pos][color] = mx;
}
int main(){
	cin>>n>>m>>x>>y;
	string s[n] ;
	for(ll i=0 ; i<n ;i++){
		cin>>s[i];
	}
	for(ll i=0 ; i<m ;i++){
		ll black=0 ;
		for(ll j=0 ; j<n ; j++){
			if(s[j][i]=='#')
				black++;
		}
		b[i] = black;
		w[i] = n-black;
	}
	for(ll i=1 ; i<m ;i++){
		b[i] += b[i-1];
		w[i] += w[i-1];
	} ll dp[m+1][3]={0};
	cout<<Barcode(2,0,0,dp)<<endl;
}


#include<bits/stdc++.h>
#define ll long long
#define N 10000001
#define vll vector<ll>
using namespace std;
ll n,m,x,y;
ll w[1001],b[1001];
ll Barcode(ll color,ll pos , ll dp[][2]){
	if(pos>=m) return 0; //cout<<"H";
	if(dp[pos][color]!=-1)
		return dp[pos][color];

	ll mx= INT_MAX;
	for(ll i =x; i<=y && pos+i-1<m ; i++){
		if(color==1){
			ll cost =(pos==0)? w[pos+i-1] : w[pos+i-1]-w[pos-1];
			mx = min(mx, cost + Barcode((color+1)%2,pos+i,dp));
		}
		else{
			ll cost =(pos==0)? b[pos+i-1] : b[pos+i-1]-b[pos-1];
			mx = min(mx, cost + Barcode((color+1)%2,pos+i,dp));
		}
	}

	return dp[pos][color] = mx;
}
int main(){
	cin>>n>>m>>x>>y;
	string s[n] ;
	for(ll i=0 ; i<n ;i++){
		cin>>s[i];
	}
	for(ll i=0 ; i<m ;i++){
		ll black=0 ;
		for(ll j=0 ; j<n ; j++){
			if(s[j][i]=='#')
				black++;
		}
		b[i] = black;
		w[i] = n-black;
	}
	for(ll i=1 ; i<m ;i++){
		b[i] += b[i-1];
		w[i] += w[i-1];
	} ll dp[m+1][2];
	memset(dp,-1,sizeof(dp));
	cout<<min(Barcode(0,0,dp), Barcode(1,0,dp))<<endl;
}

/*
10 5 3 7
.####
###..
##.##
#..#.
.#...
#.##.
.##..
.#.##
#.#..
.#..#

ans == 24
*/


#include<bits/stdc++.h>
#define ll long long
#define N 10000001
#define vll vector<ll>
using namespace std;
ll n,m,x,y;
ll w[1001],b[1001];
ll Barcode(ll color,ll pos , ll dp[][2]){
	if(pos>=m) return 0;
	if(dp[pos][color]!=0)
		return dp[pos][color];

	ll mx= INT_MAX;
	for(ll i =x; i<=y && pos+i-1<m ; i++){
		if(color==1){
			ll cost =(pos==0)? w[pos+i-1] : w[pos+i-1]-w[pos-1];
			mx = min(mx, cost + Barcode((color+1)%2,pos+i,dp));
		}
		else{
			ll cost =(pos==0)? b[pos+i-1] : b[pos+i-1]-b[pos-1];
			mx = min(mx, cost + Barcode((color+1)%2,pos+i,dp));
		}
	}

	return dp[pos][color] = mx;
}
int main(){
	cin>>n>>m>>x>>y;
	string s[n] ;
	for(ll i=0 ; i<n ;i++){
		cin>>s[i];
	}
	for(ll i=0 ; i<m ;i++){
		ll black=0 ;
		for(ll j=0 ; j<n ; j++){
			if(s[j][i]=='#')
				black++;
		}
		b[i] = black;
		w[i] = n-black;
	}
	for(ll i=1 ; i<m ;i++){
		b[i] += b[i-1];
		w[i] += w[i-1];
	} ll dp[m+1][2]={0};
	cout<<min(Barcode(0,0,dp), Barcode(1,0,dp))<<endl;
}

/*
10 5 3 7
.####
###..
##.##
#..#.
.#...
#.##.
.##..
.#.##
#.#..
.#..#

ans == 24
*/


#include<bits/stdc++.h>
#define ll long long
#define N 10000001
#define vll vector<ll>
using namespace std;
ll n,m,x,y;
ll w[1001],b[1001];
ll Barcode(ll color,ll pos ,ll price, ll dp[][3]){
	if(pos==m){
		//cout<<price<<"  ";
		return 0;
	}
	if(dp[pos][color]!=-1)
		return dp[pos][color];
	ll mx= INT_MAX;
	for(ll c=0 ;c<=1 ; c++ ){
		if(c!=color){
		for(ll i =x; i<=y && pos+i-1<m ; i++){
			if(c==1){
				ll cost =(pos==0)? w[pos+i-1] : w[pos+i-1]-w[pos-1];
				mx = min(mx, cost + Barcode(c,pos+i, price+cost,dp));
			}
			else{
				ll cost =(pos==0)? b[pos+i-1] : b[pos+i-1]-b[pos-1];
				mx = min(mx, cost + Barcode(c,pos+i, price+cost,dp));
			}
		}
		}
	}

	return dp[pos][color] = mx;
}
int main(){
	cin>>n>>m>>x>>y;
	string s[n] ;
	for(ll i=0 ; i<n ;i++){
		cin>>s[i];
	}
	for(ll i=0 ; i<m ;i++){
		ll black=0 ;
		for(ll j=0 ; j<n ; j++){
			if(s[j][i]=='#')
				black++;
		}
		b[i] = black;
		w[i] = n-black;
	}
	for(ll i=1 ; i<m ;i++){
		b[i] += b[i-1];
		w[i] += w[i-1];
	} ll dp[m+1][3];
	memset(dp,-1,sizeof(dp));
	cout<<Barcode(2,0,0,dp)<<endl;
}

/*
10 5 3 7
.####
###..
##.##
#..#.
.#...
#.##.
.##..
.#.##
#.#..
.#..#

ans == 24
*/


#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int INF = 1000000000+7;
	int n, m, x, y; cin >> n >> m >> x >> y;
	vector<vector<int>> v(m + 1, vector<int>(m + 1, INF));
	vector<int> prs(m+1);
	vector<int> prd(m+1);
	vector<vector<char>> c(n + 1, vector<char>(m + 1));
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			cin >> c[i][j];
		}
	}
	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			prs[i] += (c[j][i] == '#');
			prd[i] += (c[j][i] == '.');
		}
	}
	/*for (auto u : prs)
	{
		cout << u << ' ';
	}
	cout << '\n';
	for (auto u : prd)
	{
		cout << u << ' ';
	}*/
	for (int j = 0; j <= m; j++)
	{
		v[0][j] = 0;
	}
	for (int i = 0; i <= m; i++)
	{
		for (int j = 0; j <= m; j++)
		{
			if (i + 1 <= m)
			{
				if (j + 1 <= y && j + 1 >= x) v[i + 1][j + 1] = min(v[i + 1][j + 1], v[i][j] + prd[i + 1]);
				v[i + 1][0] = min(v[i + 1][0], v[i][j] + prs[i + 1]);
				if (j + 1 < x)
				{
					int s = 0;
					int n;
					for (n = 1; n <= m - i; n++)
					{
						s += prd[i + n];
						if (j + n >= x) break;
					}
					if (j + n <= m) v[i + n][j + n] = min(v[i + n][j + n], v[i][j] + s);
				}
			}
		}
	}
	int ans = INF;
	for (int j = 0; j <= m; j++)
	{
		ans = min(ans, v[m][j]);
	}
	cout << ans;
}


// Created by Manuver
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x << " : " << x << endl;
#define INF (1000*1000) + 1
long long n, m, x, y;
long long dp[1050][1050][2];
vector<int> pixel;

long long countPixel(long long idx, long long c) {
    return (c == 0 ? pixel[idx] : n - pixel[idx]);
}

long long minPaint(long long pc, long long count, long long idx) {
    // cout << "\nCalled with pc : " << pc << " count : " << count << " idx : " << idx << endl;
    if (idx < 0) {
        if (count >= x) return 0;
        return INF;
    }
    if (dp[idx][count][pc] != 0) return dp[idx][count][pc];

    long long rv = INF;
    if (count < y) {
        rv = countPixel(idx, pc) + minPaint(pc, count+1, idx-1);
    }
    if (count >= x) {
        rv = min(rv, countPixel(idx, 1 - pc) + minPaint(1-pc, 1, idx-1));
    }
    dp[idx][count][pc] = rv;
    return rv;
}

int main() {
    cin >> n >> m >> x >> y;
    char cur;
    pixel = vector<int>(m);
    for (long long i=0; i<n; i++) {
        for(long long j=0; j<m; j++) {
            cin >> cur;
            if (cur == '.') pixel[j]++;
        }
    }
    // for (int i=0; i<m; i++) {
    //     cout << pixel[i] << " ";
    // }
    cout << min(minPaint(0, 0, m-1), minPaint(1, 0, m-1)) << endl;
}


// Created by Manuver
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x << " : " << x << endl;
#define INF (1000*1000) + 1
long long n, m, x, y;
long long dp[1050][1050][2];
vector<int> pixel;

long long countPixel(long long idx, long long c) {
    return (c == 0 ? pixel[idx] : n - pixel[idx]);
}

long long minPaint(long long pc, long long count, long long idx) {
    // cout << "\nCalled with pc : " << pc << " count : " << " idx : " << idx << endl;
    if (idx < 0) return 0;
    if (dp[idx][count][pc] != -1) return dp[idx][count][pc];

    long long rv = INF;
    if (count < y) {
        rv = countPixel(idx, pc) + minPaint(pc, count+1, idx-1);
    }
    if (count >= x) {
        rv = min(rv, countPixel(idx, 1 - pc) + minPaint(1-pc, 1, idx-1));
    }
    dp[idx][count][pc] = rv;
    return rv;
}

int main() {
    cin >> n >> m >> x >> y;
    char cur;
    pixel = vector<int>(m);
    memset(dp, -1, sizeof dp);
    for (long long i=0; i<n; i++) {
        for(long long j=0; j<m; j++) {
            cin >> cur;
            if (cur == '.') pixel[j]++;
        }
    }
    cout << min(minPaint(0, 0, m-1), minPaint(1, 0, m-1)) << endl;
}


// Created by Manuver
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x << " : " << x << endl;
#define INF (1000*1000) + 1
int n, m, x, y;
int dp[1001][1001][2];
vector<int> pixel;

int countPixel(int idx, int c) {
    return (c == 0 ? pixel[idx] : n - pixel[idx]);
}

long long minPaint(int pc, int count, int idx) {
    // cout << "\nCalled with pc : " << pc << " count : " << " idx : " << idx << endl;
    if (idx < 0) {
        if (count >= x) return 0;
        return INF;
    }
    if (dp[idx][count][pc] != -1) return dp[idx][count][pc];
    long long rv = INF;
    if (count < y) {
        rv = countPixel(idx, pc) + minPaint(pc, count+1, idx-1);
    }
    if (count >= x) {
        rv = min(rv, countPixel(idx, 1 - pc) + minPaint(1-pc, 1, idx-1));
    }
    dp[idx][count][pc] = rv;
    return rv;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> x >> y;
    char cur;
    pixel = vector<int>(m);
    memset(dp, -1, sizeof dp);
    for (int i=0; i<n; i++) {
        for(int j=0; j<m; j++) {
            cin >> cur;
            if (cur == '.') pixel[j]++;
        }
    }
    cout << min(minPaint(0, 0, m-1), minPaint(1, 0, m-1)) << endl;
}


// Created by Manuver
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x << " : " << x << endl;
#define INF (1000*1000) + 1
int n, m, x, y;
int dp[1001][1001][2];
vector<int> pixel;

int countPixel(int idx, int c) {
    return (c == 0 ? pixel[idx] : n - pixel[idx]);
}

long long minPaint(int pc, int count, int idx) {
    // cout << "\nCalled with pc : " << pc << " count : " << " idx : " << idx << endl;
    if (idx < 0) return 0;
    if (dp[idx][count][pc] != -1) return dp[idx][count][pc];

    long long rv = INF;
    if (count < y) {
        rv = countPixel(idx, pc) + minPaint(pc, count+1, idx-1);
    }
    if (count >= x) {
        rv = min(rv, countPixel(idx, 1 - pc) + minPaint(1-pc, 1, idx-1));
    }
    dp[idx][count][pc] = rv;
    return rv;
}

int main() {
    cin >> n >> m >> x >> y;
    char cur;
    pixel = vector<int>(m);
    memset(dp, -1, sizeof dp);
    for (int i=0; i<n; i++) {
        for(int j=0; j<m; j++) {
            cin >> cur;
            if (cur == '.') pixel[j]++;
        }
    }
    cout << min(minPaint(0, 0, m-1), minPaint(1, 0, m-1)) << endl;
}


// Created by Manuver
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x << " : " << x << endl;
#define INF (1000*1000) + 1
int n, m, x, y;
int dp[1001][1001][2];
vector<int> pixel;

int countPixel(int idx, int c) {
    return (c == 0 ? pixel[idx] : n - pixel[idx]);
}

long long minPaint(int pc, int count, int idx) {
    // cout << "\nCalled with pc : " << pc << " count : " << " idx : " << idx << endl;
    if (idx < 0) {
        if (count >= x) return 0;
        return INF;
    }
    if (dp[idx][count][pc] != -1) return dp[idx][count][pc];
    long long rv = INF;
    if (count < y) {
        rv = countPixel(idx, pc) + minPaint(pc, count+1, idx-1);
    }
    if (count >= x) {
        rv = min(rv, countPixel(idx, 1 - pc) + minPaint(1-pc, 1, idx-1));
    }
    dp[idx][count][pc] = rv;
    return rv;
}

int main() {
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    cin >> n >> m >> x >> y;
    char cur;
    pixel = vector<int>(m);
    memset(dp, -1, sizeof dp);
    for (int i=0; i<n; i++) {
        for(int j=0; j<m; j++) {
            cin >> cur;
            if (cur == '.') pixel[j]++;
        }
    }
    cout << min(minPaint(0, 0, m-1), minPaint(1, 0, m-1)) << endl;
}


//Author - sorablaze_11
#include <bits/stdc++.h>

using namespace std;

int n, m, x, y, cntBlack, cntWhite, prefWhite[1010], prefBlack[1010], dp[2][1010];
char arr[1010][1010];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    scanf("%d %d %d %d", &n, &m, &x, &y);
    for(int i = 0; i < n; i++) scanf("%s", &arr[i]);
    for(int i = 0; i < m; i++){
        for(int j = 0; j < n; j++){
            cntBlack += (arr[j][i] == '#');
            cntWhite += (arr[j][i] == '.');
        }
        prefBlack[i + 1] = cntBlack;
        prefWhite[i + 1] = cntWhite;
    }
    for(int i = 1; i < 1010;i++) dp[0][i] = dp[1][i] = 1000000007;
    for(int i = 1; i <= m; i++){
        for(int j = x; j <= y; j++){
            if(i - j >= 0){
                dp[0][i] = min(dp[0][i], dp[1][i - j] + prefBlack[i] - prefBlack[i - j]);
                dp[1][i] = min(dp[1][i], dp[0][i - j] + prefWhite[i] - prefWhite[i - j]);
            }
        }
    }
    printf("%d\n", min(dp[0][m], dp[1][m]));
    return 0;
}


//Author - sorablaze_11
#include <bits/stdc++.h>

using namespace std;

int n, m, x, y, cntBlack, cntWhite, prefWhite[1010], prefBlack[1010], dp[2][1010];
char arr[1010][1010];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    scanf("%d %d %d %d", &n, &m, &x, &y);
    for(int i = 0; i < n; i++) scanf("%s", &arr[i]);
    for(int i = 0; i < m; i++){
        for(int j = 0; j < n; j++){
            cntBlack += (arr[j][i] == '#');
            cntWhite += (arr[j][i] == '.');
        }
        prefBlack[i + 1] = cntBlack;
        prefWhite[i + 1] = cntWhite;
    }
    for(int i = 1; i < 1010;i++) dp[0][i] = dp[1][i] = 1000000007;
    for(int i = 1; i <= m; i++){
        for(int j = y; j >= x; j--){
            if(i - j >= 0){
                dp[0][i] = min(dp[0][i], dp[1][i - j] + prefWhite[i] - prefWhite[i - j]);
                dp[1][i] = min(dp[1][i], dp[0][i - j] + prefBlack[i] - prefBlack[i - j]);
            }
        }
    }
    printf("%d\n", min(dp[0][m], dp[1][m]));
    return 0;
}


//Author - sorablaze_11
#include <bits/stdc++.h>

using namespace std;

int n, m, x, y, cntBlack, cntWhite, prefWhite[1010], prefBlack[1010], dp[2][1010];
char arr[1010][1010];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    scanf("%d %d %d %d", &n, &m, &x, &y);
    for(int i = 0; i < n; i++) scanf("%s", &arr[i]);
    for(int i = 0; i < m; i++){
        for(int j = 0; j < n; j++){
            cntBlack += (arr[j][i] == '#');
            cntWhite += (arr[j][i] == '.');
        }
        prefBlack[i + 1] = cntBlack;
        prefWhite[i + 1] = cntWhite;
    }
    for(int i = 1; i < 1010;i++) dp[0][i] = dp[1][i] = 1000000007;
    for(int i = 1; i <= m; i++){
        for(int j = x; j <= y; j++){
            if(i - j >= 0){
                dp[0][i] = min(dp[0][i], dp[1][i - j] + prefWhite[i] - prefWhite[i - j]);
                dp[1][i] = min(dp[1][i], dp[0][i - j] + prefBlack[i] - prefBlack[i - j]);
            }
        }
    }
    printf("%d\n", min(dp[0][m], dp[1][m]));
    return 0;
}


//Author - sorablaze_11
#include <bits/stdc++.h>

using namespace std;

#define rep(i,a,n) for(int i = a; i < n ; i++)
#define per(i,a,n) for(int i = n - 1; i >= a;i--)
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define mod 1000000007
#define inf 0x3f3f3f3f
#define pb push_back
#define em emplace_back
#define mp make_pair
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ll long long int
#define ull unsigned ll
#define ld long double

inline ll gcd(ll a,ll b) { return b ? gcd(b, a % b): a;}
inline ll fast_pow(ll a, ll b) {ll res = 1; a %= mod; assert(b >= 0); for(;b;b >>= 1){ if(b & 1) res = res * a % mod; a = a * a % mod; } return res;}
inline bool isPrime(ll a){ for(ll i = 2; i * i <= a; i++) if(a % i == 0) return 0; return 1;}

string a, b;
stack<int> s, ss;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cin >> a >> b;
    sort(all(a), greater<char>());
    if(b.size() > a.size()){
        cout << a << '\n';
    }else{
        vector<int> A(a.size()), B(a.size());
        for(int i = 0; i < a.size(); i++) A[i] = a[i] - '0';
        int curr = 0, max_, temp, pos, temppos, l;
        bool flag;
        for(int i = 0; i < b.size(); i++){
            curr *= 10;
            curr += b[i] - '0';
            max_ = INT_MIN;
            flag = false;
            for(int j = 0; j < a.size(); j++){
                if(A[j] != -1 && max_ < A[j] && A[j] <= curr){
                    pos = j;
                    max_ = A[j];
                    flag = true;
                }
            }
            if(flag){
                //cout << "1 " << curr << ' ' << A[pos] << '\n';
                s.push(A[pos]);
                ss.push(pos);
                B[i] = curr;
                curr -= A[pos];
                A[pos] = -1;
            }else{
                //cout << "2 " << curr << '\n';
                flag = true;
                l = 0;
                while(flag){
                    l++;
                    pos = ss.top();
                    ss.pop();
                    temp = s.top();
                    s.pop();
                    max_ = INT_MIN;
                    A[pos] = temp;
                    for(int j = 0; j < a.size(); j++){
                        if(A[j] != -1 && A[j] < temp && A[j] > max_){
                            temppos = j;
                            max_ = A[j];
                            flag = false;
                        }
                    }
                }
                ss.push(temppos);
                s.push(A[temppos]);
                curr = B[i - l] - A[temppos];
                i -= l;
                //cout << i << ' ' << curr << ' ' << A[temppos] << '\n';
                A[temppos] = -1;
            }
        }
        //cout << s.size() << '\n';
        int i = s.size() - 1;
        while(!s.empty()){
            A[i] = s.top();
            s.pop();
            i--;
        }
        for(int i = 0; i < a.size(); i++) cout << A[i];
        cout << '\n';
    }
    return 0;
}


//Author - sorablaze_11
#include <bits/stdc++.h>

using namespace std;

int n, m, x, y, cntBlack, cntWhite, prefWhite[1010], prefBlack[1010], dp[2][1010];
char arr[1010][1010];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    scanf("%d %d %d %d", &n, &m, &x, &y);
    for(int i = 0; i < n; i++) scanf("%s", &arr[i]);
    for(int i = 0; i < m; i++){
        for(int j = 0; j < n; j++){
            cntBlack += (arr[j][i] == '#');
            cntWhite += (arr[j][i] == '.');
        }
        prefBlack[i + 1] = cntBlack;
        prefWhite[i + 1] = cntWhite;
    }
    for(int i = 1; i < 1010;i++) dp[0][i] = dp[1][i] = 1000000007;
    for(int i = 1; i <= m; i++){
        for(int j = x; j >= x; j--)y
            if(i - j >= 0){
                dp[0][i] = min(dp[0][i], dp[1][i - j] + prefWhite[i] - prefWhite[i - j]);
                dp[1][i] = min(dp[1][i], dp[0][i - j] + prefBlack[i] - prefBlack[i - j]);
            }
        }
    }
    printf("%d\n", min(dp[0][m], dp[1][m]));
    return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<iomanip>
#include<map>
#include<cmath>
#include<algorithm>
#include <cstring>
using namespace std ;
#define khaledOsama ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define re return
#define lp(i,e) for(int i=0;i<e;i++)
#define pb push_back
#define clr(v, d) memset(v, d, sizeof(v))
#define mp make_pair
#define ln length()
typedef long long ll;
typedef unsigned long long ull;
int n,m,x,y;
int dot[1001]={};
int mem[1002][1002][3];
int DP(int i,int prev,int width){
if(i==m)
    re 0;
int &ans=mem[i][prev][width];
if(ans!=-1)
    re ans;

int a=10e6;

 if(!i||(!prev&&width+1<=y)||(prev&&width>=x))
    a=(prev)?n-dot[i]+DP(i+1,0,1):n-dot[i]+DP(i+1,0,width+1);

 int b=1000000;
 if(!i||(prev&&width+1<=y)||(!prev&&width>=x))
    b=(prev)?dot[i]+DP(i+1  ,1,width+1):dot[i]+DP(i+1,1,1);

    ans=min(a,b);
    re ans;
}
   int main(){
khaledOsama;
cin>>n>>m>>x>>y;
lp(i,n){
lp(j,m){
char ch;
cin>>ch;
if(ch=='.')
    dot[j]++;
}
}
clr(mem,-1);
cout<<DP(0,5,0)<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define endl '\n';
typedef long long ll;

int main()
{
    ll i,j,k,l,m,n,low,hi,cnt=0,ans=0;
    cin>>n>>m>>k;
    ll a[m+10];
    for(i=0; i<m; i++)
        cin>>a[i];
    sort(a,a+m);
    i=0;
    while(i<m)
    {
        low = (a[i]+k-1)/k;
        hi = low*k;
        low = hi-k+1;
        low+=cnt;
        hi+=cnt;
        if(low<=a[i] && a[i]<=hi && i<m)
        {
            while(low<=a[i] && a[i]<=hi && i<m)
            {
                i++;
                cnt++;
            }
            ans++;
        }
        hi += cnt;
       // cout<<a[i]<<endl;
        if(a[i]<=hi && i<m)
        {
            while(a[i]<=hi && i<m)i++,cnt++;
            ans++;
        }
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define endl '\n';
typedef long long ll;

int main()
{
    ll i,j,k,l,m,n,low,hi,cnt=0,ans=0,p;
    cin>>n>>m>>k;
    ll a[m+10];
    for(i=0; i<m; i++)
        cin>>a[i];
    sort(a,a+m);
    i=0;
    while(i<m)
    {
        low = (a[i]+k-1)/k;
        hi = low*k;
        low = hi-k+1;
        cnt=0;
        if(low<=a[i] && a[i]<=hi && i<m)
        {
            while(low<=a[i] && a[i]<=hi && i<m)
            {
                i++;
                cnt++;
            }
            ans++;
        }
        hi += cnt;
        // cout<<a[i]<<endl;
        if(a[i]<=hi && i<m)
        {
            p=0;
            while(a[i]<=p && i)
            {
                while(a[i]<=hi && i<m)
                    i++,cnt++,p++;
            p+=a[i];
                ans++;
            }
            ans++;
        }
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define endl '\n';
typedef long long ll;

int main()
{
    ll i,j,k,l,m,n,low,hi,cnt=0,ans=0,p;
    cin>>n>>m>>k;
    ll a[m+10];
    for(i=0; i<m; i++)
        cin>>a[i];
    sort(a,a+m);
    i=0;
    while(i<m)
    {
        low = (a[i]+k-1)/k;
        hi = low*k;
        low = hi-k+1;
        cnt=0;
        if(low<=a[i] && a[i]<=hi && i<m)
        {
            while(low<=a[i] && a[i]<=hi && i<m)
            {
                i++;
                cnt++;
            }
            ans++;
        }
        hi += cnt;
        // cout<<a[i]<<endl;
        if(a[i]<=hi && i<m)
        {
            p=0;
            while(a[i]<=p && i)
            {
                while(a[i]<=hi && i<m)
                    i++,cnt++,p++;
            p+=a[i];
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define endl '\n';
typedef long long ll;

int main()
{
    ll i,j,k,l,m,n,low,hi,cnt=0,ans=0,f=0;
    cin>>n>>m>>k;
    ll a[m+10];
    for(i=0; i<m; i++)
        cin>>a[i];
   // sort(a,a+m);
    i=0;
    while(i<m)
    {
        hi = (a[i]-cnt+k-1)/k;
        hi = hi*k;
        f=0;
        while(a[i]-cnt<=hi)
        {
            i++;
            f++;
        }
        cnt+=f;
        ans++;

    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll cnt;

int  main()
{
    ll i,k,j,l,m,n,ans=1,x,prev,now,minu;

    cin>>n>>m>>k;

    ll a[m+10];

    for(i=0;i<m;i++)cin>>a[i];
sort(a,a+m);
now = a[0]+k-1;
now/=k;
minu=0;
  for(i=0;i<m;i++)
  {
      prev=now;
      now=(a[i]-minu+k-1)/k;
    //  cout<<prev<<" "<<now<<endl;
      if(now!=prev)
      {
          minu+=cnt;
          now = (a[i]-minu+k-1)/k;
          cnt=1;
          minu++;
          ans++;
         // cout<<minu<<endl;
      }
      else cnt++;
  }

    cout<<ans<<endl;

}


#include<bits/stdc++.h>
using namespace std;
#define endl '\n';
typedef long long ll;

int main()
{
    ll i,j,k,l,m,n,low,hi,cnt=0,ans=0;
    cin>>n>>m>>k;
    ll a[m+10];
    for(i=0; i<m; i++)
        cin>>a[i];
    sort(a,a+m);
    i=0;
    while(i<m)
    {
        low = (a[i]+k-1)/k;
        hi = low*k;
        low = hi-k+1;
      cnt=0;
        if(low<=a[i] && a[i]<=hi && i<m)
        {
            while(low<=a[i] && a[i]<=hi && i<m)
            {
                i++;
                cnt++;
            }
            ans++;
        }
        hi += cnt;
       // cout<<a[i]<<endl;
        if(a[i]<=hi && i<m)
        {
            while(a[i]<=hi && i<m)i++,cnt++;
            ans++;
        }
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll cnt[1000009];

int  main()
{
    ll i,k,j,l,m,n,ans=1,x;

    cin>>n>>m>>k;

    ll a[m+10];

    for(i=0;i<m;i++)cin>>a[i];

    for(i=0;i<m;i++)
    {
        l = (a[i]+k-1)/k;
      // cout<<l<<endl;
        if(cnt[l]==0 && i)
        {
            ans++;
            cnt[l]++;
            x = a[i-1];
            l = (x+k-1)/k;
            x = x + cnt[l] ;
           // cout<<x<<" "<<i<<endl;
            if(x<=a[i])ans++;
        }
        else cnt[l]++;
    }

    cout<<ans<<endl;

}


#include<iostream>
#include<cstdio>
#include<set>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
using namespace std;
long long a[100005];
long long n,m,k;
long long l,r;
const long long mod=1e18;
int main()
{

    long long s=0;
    long long s1=0;
    long long de=0;
    scanf("%I64d%I64d%I64d",&n,&m,&k);
    l=1;
    r=k;
    for(int i=0;i<m;i++)
    {
        if(a[i]==0)
        {
            scanf("%I64d",&a[i]);
        }
        if((a[i]-s)>=l&&(a[i]-s)<=r)
        {
            if(s1==0)
            {
                de++;
            }
            s1++;
        }
        else if(s1==0&&(a[i]-s)>r)
        {
            if(mod-l<k)
            {
                break;
            }
            else
            {
                l+=k;
            }
            if(mod-r<k)
            {
                r=mod;
            }
            else
            {
                r+=k;
            }
            i--;
        }
        else if(s1!=0&&(a[i]-s)>r)
        {
            s+=s1;
            s1=0;
            i--;
        }
    }
    printf("%I64d\n",de);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<set>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
using namespace std;
long long a[100005];
long long n,m,k;
long long l,r;
const long long mod=1e18;
int main()
{
    scanf("%I64d%I64d%I64d",&n,&m,&k);
    for(int i=0;i<m;i++)
    {
        scanf("%I64d",&a[i]);
    }
    l=1;
    r=k;
    long long s=0;
    long long s1=0;
    long long de=0;
    for(int i=0;i<m;i++)
    {
        if((a[i]-s)>=l&&(a[i]-s)<=r)
        {
            if(s1==0)
            {
                de++;
            }
            s1++;
        }
        else if(s1==0&&(a[i]-s)>r)
        {
            l=k+l;
            if(mod-r<k)
            {
                r=mod;
            }
            else
            {
                r+=k;
            }
            i--;

        }
        else if(s1!=0&&(a[i]-s)>r)
        {
            s+=s1;
            s1=0;
            i--;
        }
    }
    printf("%I64d\n",de);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<set>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
using namespace std;
long long a[100005];
long long n,m,k;
long long l,r;
const long long mod=1e18;
int main()
{

    long long s=0;
    long long s1=0;
    long long de=0;
    scanf("%I64d%I64d%I64d",&n,&m,&k);
    l=1;
    r=k;
    for(int i=0; i<m; i++)
    {
        if(a[i]==0)
        {
            scanf("%I64d",&a[i]);
        }

    }
    if(k==1)
    {
        printf("%I64d\n",m);
    }
    else
    {
        for(int i=0; i<m; i++)
        {
            if((a[i]-s)>=l&&(a[i]-s)<=r)
            {
                if(s1==0)
                {
                    de++;
                }
                s1++;
            }
            else if(s1==0&&(a[i]-s)>r)
            {
                if(mod-l<k)
                {
                    break;
                }
                else
                {
                    l+=((a[i]-s-l)/k)*k;
                }
                if(mod-r<k)
                {
                    r=mod;
                }
                else
                {
                    r+=((a[i]-s-l)/k)*k;
                }
                i--;
            }
            else if(s1!=0&&(a[i]-s)>r)
            {
                s+=s1;
                s1=0;
                i--;
            }
        }
        printf("%I64d\n",de);
    }

    return 0;
}


#include<iostream>
#include<cstdio>
#include<set>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
using namespace std;
long long a[100005];
long long n,m,k;
long long l,r;
const long long mod=1e18;
int main()
{

    long long s=0;
    long long s1=0;
    long long de=0;
    scanf("%I64d%I64d%I64d",&n,&m,&k);
    l=1;
    r=k;
    for(int i=0;i<m;i++)
    {
        if(a[i]==0)
        {
            scanf("%I64d",&a[i]);
        }
        if((a[i]-s)>=l&&(a[i]-s)<=r)
        {
            if(s1==0)
            {
                de++;
            }
            s1++;
        }
        else if(s1==0&&(a[i]-s)>r)
        {
            if(mod-l<k)
            {
                break;
            }
            else
            {
                l+=k;
            }
            if(mod-r<k)
            {
                r=mod;
            }
            else
            {
                r+=k;
            }
            i--;

        }
        else if(s1!=0&&(a[i]-s)>r)
        {
            s+=s1;
            s1=0;
            i--;
        }
    }
    printf("%I64d\n",de);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<set>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
using namespace std;
long long a[100005];
long long n,m,k;
long long l,r;
const long long mod=1e18;
int main()
{

    long long s=0;
    long long s1=0;
    long long de=0;
    scanf("%I64d%I64d%I64d",&n,&m,&k);
    l=1;
    r=k;
    for(int i=0; i<m; i++)
    {
        if(a[i]==0)
        {
            scanf("%I64d",&a[i]);
        }

    }
    if(k==1)
    {
        printf("%I64d\n",m);
    }
    else
    {
        for(int i=0; i<m; i++)
        {
            //printf("%I64d %I64d %I64d\n",a[i],l,r);
            if((a[i]-s)>=l&&(a[i]-s)<=r)
            {
                if(s1==0)
                {
                    de++;
                }
                s1++;
            }
            else if(s1==0&&(a[i]-s)>r)
            {
                if(mod-l<k)
                {
                    break;
                }
                else
                {
                    l+=(a[i]-s-l-(a[i]-s-l)%k);

                }
                if(mod-r<k)
                {
                    r=mod;
                }
                else
                {
                    r+=(((a[i]-s-r-1)/k)*k+k);
                }
                i--;
            }
            else if(s1!=0&&(a[i]-s)>r)
            {
                s+=s1;
                s1=0;
                i--;
            }
        }
        printf("%I64d\n",de);
    }

    return 0;
}


#include<iostream>
#include<cstdio>
#include<set>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
using namespace std;
long long a[100005];
long long n,m,k;
long long l,r;
const long long mod=1e18;
int main()
{

    long long s=0;
    long long s1=0;
    long long de=0;
    scanf("%I64d%I64d%I64d",&n,&m,&k);
    l=1;
    r=k;
    for(int i=0; i<m; i++)
    {
        if(a[i]==0)
        {
            scanf("%I64d",&a[i]);
        }

    }
    if(k==1)
    {
        printf("%I64d\n",m);
    }
    else
    {
        for(int i=0; i<m; i++)
        {
            if((a[i]-s)>=l&&(a[i]-s)<=r)
            {
                if(s1==0)
                {
                    de++;
                }
                s1++;
            }
            else if(s1==0&&(a[i]-s)>r)
            {
                if(mod-l<k)
                {
                    break;
                }
                else
                {
                    l+=(a[i]-s-l-(a[i]-s-l)%k);

                }
                if(mod-r<k)
                {
                    r=mod;
                }
                else
                {
                    r+=(a[i]-s-r-(a[i]-s-r)%k+k);
                }
                i--;
            }
            else if(s1!=0&&(a[i]-s)>r)
            {
                s+=s1;
                s1=0;
                i--;
            }
        }
        printf("%I64d\n",de);
    }

    return 0;
}


#include<iostream>
#include<cstdio>
#include<set>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
using namespace std;
long long a[100005];
long long n,m,k;
long long l,r;
const long long mod=1e18;
int main()
{
    scanf("%I64d%I64d%I64d",&n,&m,&k);
    for(int i=0;i<m;i++)
    {
        scanf("%I64d",&a[i]);
    }
    l=1;
    r=k;
    long long s=0;
    long long s1=0;
    long long de=0;
    for(int i=0;i<m;i++)
    {
        if((a[i]-s)>=l&&(a[i]-s)<=r)
        {
            if(s1==0)
            {
                de++;
            }
            s1++;
        }
        else if(s1==0&&(a[i]-s)>r)
        {
            if(mod-l<k)
            {
                break;
            }
            else
            {
                l+=k;
            }
            if(mod-r<k)
            {
                r=mod;
            }
            else
            {
                r+=k;
            }
            i--;

        }
        else if(s1!=0&&(a[i]-s)>r)
        {
            s+=s1;
            s1=0;
            i--;
        }
    }
    printf("%I64d\n",de);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<set>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
using namespace std;
long long a[100005];
long long n,m,k;
long long l,r;
const int mod=1e18;
int main()
{
    scanf("%I64d%I64d%I64d",&n,&m,&k);
    for(int i=0;i<m;i++)
    {
        scanf("%I64d",&a[i]);
    }
    l=1;
    r=k;
    long long s=0;
    long long s1=0;
    long long de=0;
    for(int i=0;i<m;i++)
    {
        if((a[i]-s)>=l&&(a[i]-s)<=r)
        {
            if(s1==0)
            {
                de++;
            }
            s1++;
        }
        else if(s1==0&&(a[i]-s)>r)
        {
            l=k+l;
            if(mod-r<k)
            {
                r=mod;
            }
            i--;

        }
        else if(s1!=0&&(a[i]-s)>r)
        {
            s+=s1;
            s1=0;
            i--;
        }
    }
    printf("%I64d\n",de);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<set>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
using namespace std;
long long a[100005];
long long n,m,k;
long long l,r;
const long long mod=1e18;
int main()
{

    long long s=0;
    long long s1=0;
    long long de=0;
    scanf("%I64d%I64d%I64d",&n,&m,&k);
    l=1;
    r=k;
    for(int i=0;i<m;i++)
    {
        if(a[i]==0)
        {
            scanf("%I64d",&a[i]);
        }
        else{
        if((a[i]-s)>=l&&(a[i]-s)<=r)
        {
            if(s1==0)
            {
                de++;
            }
            s1++;
        }
        else if(s1==0&&(a[i]-s)>r)
        {
            if(mod-l<k)
            {
                break;
            }
            else
            {
                l+=k;
            }
            if(mod-r<k)
            {
                r=mod;
            }
            else
            {
                r+=k;
            }
            i--;
        }
        else if(s1!=0&&(a[i]-s)>r)
        {
            s+=s1;
            s1=0;
            i--;
        }
        }
    }
    printf("%I64d\n",de);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<set>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
using namespace std;
long long a[100005];
long long n,m,k;
long long l,r;
int main()
{
    scanf("%I64d%I64d%I64d",&n,&m,&k);
    for(int i=0;i<m;i++)
    {
        scanf("%I64d",&a[i]);
    }
    l=1;
    r=k;
    long long s=0;
    long long s1=0;
    long long de=0;
    for(int i=0;i<m;i++)
    {
        if((a[i]-s)>=l&&(a[i]-s)<=r)
        {
            if(s1==0)
            {
                de++;
            }
            s1++;
        }
        else if(s1==0&&(a[i]-s)>r)
        {
            l+=k;
            r+=k;
            i--;

        }
        else if(s1!=0&&(a[i]-s)>r)
        {
            s+=s1;
            s1=0;
            i--;
        }
    }
    printf("%I64d\n",de);
    return 0;
}


#include <bits/stdc++.h>
#if !defined(ONLINE_JUDGE)
#include "prettyprint.hpp"
#endif

#define ent(smth) smth.begin(), smth.end()
#define fori(i,n) for(intel i = 0; i < n; i++)
#define forn(n) for(intel i = 0; i < n; ++i)
#define forx(i,x,n) for(intel i = x; i < n; i++)
#define iter_for(_cont, _iterator) for(auto _iterator  = _cont.begin(); _iterator != _cont.end(); ++_iterator)

using namespace std;
typedef long long intel;
typedef pair<int, int> pInt;
int main()
{
    intel n, m, k; cin >> n >> m >> k;
    intel _k = k, lastk = 0;
    vector<intel> p(m); for(auto &x : p) cin >> x;
    int act = 0;
    while(m > 0)
    {
        intel l = lastk, r = p.size() + 1;
        while(r - l > 1)
        {
            int mid = (r + l)/2;
            if(p[mid] <= k ) l = mid;
            else r = mid;
        }

        if(p[l] <= k) {
            k += (l - lastk + 1);
            m -= (l - lastk + 1);
            lastk = l + 1;
            act++;
            // cout << "FIRST\n";
        }
        else {
           k += _k * ((p[lastk] - k) / _k + (bool)(p[lastk - k] % k));
        }
    } cout << act;
}


#include <bits/stdc++.h>
#if !defined(ONLINE_JUDGE)
#include "prettyprint.hpp"
#endif

#define ent(smth) smth.begin(), smth.end()
#define fori(i,n) for(intel i = 0; i < n; i++)
#define forn(n) for(intel i = 0; i < n; ++i)
#define forx(i,x,n) for(intel i = x; i < n; i++)
#define iter_for(_cont, _iterator) for(auto _iterator  = _cont.begin(); _iterator != _cont.end(); ++_iterator)

using namespace std;
typedef long long intel;
typedef pair<int, int> pInt;
int main()
{
    intel n, m, k; cin >> n >> m >> k;
    intel _k = k, lastk = 0;
    vector<intel> p(m); for(auto &x : p) cin >> x;
    int act = 0;
    while(m > 0)
    {
        intel l = lastk, r = p.size() + 1;
        // printf("Search for %I64d\n", k);
        while(r - l > 1)
        {
            int mid = (r + l)/2;
            if(p[mid] <= k ) l = mid;
            else r = mid;
        }
        //printf("Found %I64d on %I64d\n", p[l], l + 1LL);
        if(p[l] <= k) {
            k += (l - lastk + 1);
            m -= (l - lastk + 1);
            lastk = l + 1;
            act++;
            // cout << "FIRST\n";
        }
        else {
            k = k + _k*((p[lastk] - k) / _k + min(1LL,(p[lastk] - k) % _k));
        }
        // printf("Ended with %I64d and lastK = %I64d\n\n", l + 1LL, lastk);
    } cout << act;
}


#include <bits/stdc++.h>
#if !defined(ONLINE_JUDGE)
#include "prettyprint.hpp"
#endif

#define ent(smth) smth.begin(), smth.end()
#define fori(i,n) for(intel i = 0; i < n; i++)
#define forn(n) for(intel i = 0; i < n; ++i)
#define forx(i,x,n) for(intel i = x; i < n; i++)
#define iter_for(_cont, _iterator) for(auto _iterator  = _cont.begin(); _iterator != _cont.end(); ++_iterator)

using namespace std;
typedef long long intel;
typedef pair<int, int> pInt;
int main()
{
    intel n, m, k; cin >> n >> m >> k;
    intel _k = k, lastk = 0;
    vector<intel> p(m); for(auto &x : p) cin >> x;
    int act = 0;
    while(m > 0)
    {
        intel l = lastk, r = p.size() + 1;
        // printf("Search for %I64d\n", k);
        while(r - l > 1)
        {
            int mid = (r + l)/2;
            if(p[mid] <= k ) l = mid;
            else r = mid;
        }
        //printf("Found %I64d on %I64d\n", p[l], l + 1LL);
        if(p[l] <= k) {
            k += (l - lastk + 1);
            m -= (l - lastk + 1);
            lastk = l + 1;
            act++;
            // cout << "FIRST\n";
        }
        else {
           k += _k * ((p[lastk] - k) / _k + (bool)(p[lastk - k] % k));
        }
        // printf("Ended with %I64d and lastK = %I64d\n\n", l + 1LL, lastk);
    } cout << act;
}


#include <bits/stdc++.h>
#if !defined(ONLINE_JUDGE)
#include "prettyprint.hpp"
#endif

#define ent(smth) smth.begin(), smth.end()
#define fori(i,n) for(intel i = 0; i < n; i++)
#define forn(n) for(intel i = 0; i < n; ++i)
#define forx(i,x,n) for(intel i = x; i < n; i++)
#define iter_for(_cont, _iterator) for(auto _iterator  = _cont.begin(); _iterator != _cont.end(); ++_iterator)

using namespace std;
typedef long long intel;
typedef pair<int, int> pInt;
int main()
{
    intel n, m, k; cin >> n >> m >> k;
    intel _k = k, lastk = 0;
    vector<intel> p(m); for(auto &x : p) cin >> x;
    int act = 0;
    while(m > 0)
    {
        intel l = lastk, r = p.size() + 1;
        fprintf(stderr, "Search for %I64d\n", k);
        while(r - l > 1)
        {
            int mid = (r + l)/2;
            if(p[mid] <= k ) l = mid;
            else r = mid;
        }
        fprintf(stderr,"Found %I64d on %I64d\n", p[l], l + 1LL);
        if(p[l] <= k) {
           k += (l - lastk + 1);
           m -= (l - lastk + 1);
           lastk = l + 1;
           act++;
           fprintf(stderr,"FIRST\n");
        }
        else
        {
            intel j = (p[lastk] - 1) - (p[lastk] - 1) % _k;
            fprintf(stderr, "I64d", j);
            if((p[lastk] - 1) % _k) j += _k;
            k = j + 1;
        }
        fprintf(stderr,"Ended with %I64d and lastK = %I64d\n\n", l + 1LL, lastk);
    } cout << act;
}


#include <bits/stdc++.h>
#if !defined(ONLINE_JUDGE)
#include "prettyprint.hpp"
#endif

#define ent(smth) smth.begin(), smth.end()
#define fori(i,n) for(intel i = 0; i < n; i++)
#define forn(n) for(intel i = 0; i < n; ++i)
#define forx(i,x,n) for(intel i = x; i < n; i++)
#define iter_for(_cont, _iterator) for(auto _iterator  = _cont.begin(); _iterator != _cont.end(); ++_iterator)

using namespace std;
typedef long long intel;
typedef pair<int, int> pInt;
int main()
{
    intel n, m, k; cin >> n >> m >> k;
    intel _k = k, lastk = 0;
    vector<intel> p(m); for(auto &x : p) cin >> x;
    int act = 0;
    while(m > 0)
    {
        intel l = lastk, r = p.size() + 1;
        //printf("Search for %I64d\n", k);
        while(r - l > 1)
        {
            int mid = (r + l)/2;
            if(p[mid] <= k ) l = mid;
            else r = mid;
        }
       // printf("Found %I64d on %I64d\n", p[l], l + 1LL);
        if(p[l] <= k) {
           k += (l - lastk + 1);
           m -= (l - lastk + 1);
           lastk = l + 1;
           act++;
          // cout << "FIRST\n";
        }
        else
        {
            int j = (p[lastk] - 1) - (p[lastk] - 1) % _k;
           // cout << j << endl;
            j += _k;
            k = j;
        }
        //printf("Ended with %I64d and lastK = %I64d\n\n", l + 1LL, lastk);
    } cout << act;
}


#include <bits/stdc++.h>
#if !defined(ONLINE_JUDGE)
#include "prettyprint.hpp"
#endif

#define ent(smth) smth.begin(), smth.end()
#define fori(i,n) for(intel i = 0; i < n; i++)
#define forn(n) for(intel i = 0; i < n; ++i)
#define forx(i,x,n) for(intel i = x; i < n; i++)
#define iter_for(_cont, _iterator) for(auto _iterator  = _cont.begin(); _iterator != _cont.end(); ++_iterator)

using namespace std;
typedef long long intel;
typedef pair<int, int> pInt;
int main()
{
    intel n, m, k; cin >> n >> m >> k;
    intel _k = k, lastk = 0;
    vector<intel> p(m); for(auto &x : p) cin >> x;
    int act = 0;
    while(m > 0)
    {
        intel l = lastk, r = p.size() + 1;
       // printf("Search for %I64d\n", k);
        while(r - l > 1)
        {
            int mid = (r + l)/2;
            if(p[mid] <= k ) l = mid;
            else r = mid;
        }
        //printf("Found %I64d on %I64d\n", p[l], l + 1LL);
        if(p[l] <= k) {
           k += (l - lastk + 1);
           m -= (l - lastk + 1);
           lastk = l + 1;
           act++;
          // cout << "FIRST\n";
        }
        else k += _k;
       // printf("Ended with %I64d and lastK = %I64d\n\n", l + 1LL, lastk);
    } cout << act;
}


#include <bits/stdc++.h>
#if !defined(ONLINE_JUDGE)
#include "prettyprint.hpp"
#endif

#define ent(smth) smth.begin(), smth.end()
#define fori(i,n) for(intel i = 0; i < n; i++)
#define forn(n) for(intel i = 0; i < n; ++i)
#define forx(i,x,n) for(intel i = x; i < n; i++)
#define iter_for(_cont, _iterator) for(auto _iterator  = _cont.begin(); _iterator != _cont.end(); ++_iterator)

using namespace std;
typedef long long intel;
typedef pair<int, int> pInt;
int main()
{
    intel n, m, k; cin >> n >> m >> k;
    intel _k = k, lastk = 0;
    vector<intel> p(m); for(auto &x : p) cin >> x;
    int act = 0;
    while(m > 0)
    {
        intel l = lastk, r = p.size() + 1;
         //printf("Search for %I64d\n", k);
        while(r - l > 1)
        {
            int mid = (r + l)/2;
            if(p[mid] <= k ) l = mid;
            else r = mid;
        }
        //printf("Found %I64d on %I64d\n", p[l], l + 1LL);
        if(p[l] <= k) {
            k += (l - lastk + 1);
            m -= (l - lastk + 1);
            lastk = l + 1;
            act++;
            // cout << "FIRST\n";
        }
        else {
           k = (p[lastk] + _k) - ((p[lastk] - 1) % _k);
        }
        // printf("Ended with %I64d and lastK = %I64d\n\n", l + 1LL, lastk);
    } cout << act;
}


#include <bits/stdc++.h>
#if !defined(ONLINE_JUDGE)
#include "prettyprint.hpp"
#endif

#define ent(smth) smth.begin(), smth.end()
#define fori(i,n) for(intel i = 0; i < n; i++)
#define forn(n) for(intel i = 0; i < n; ++i)
#define forx(i,x,n) for(intel i = x; i < n; i++)
#define iter_for(_cont, _iterator) for(auto _iterator  = _cont.begin(); _iterator != _cont.end(); ++_iterator)

using namespace std;
typedef long long intel;
typedef pair<int, int> pInt;
int main()
{
    intel n, m, k; cin >> n >> m >> k;
    intel _k = k, lastk = 0;
    vector<intel> p(m); for(auto &x : p) cin >> x;
    int act = 0;
    while(m > 0)
    {
        intel l = lastk, r = p.size() + 1;
         //printf("Search for %I64d\n", k);
        while(r - l > 1)
        {
            int mid = (r + l)/2;
            if(p[mid] <= k ) l = mid;
            else r = mid;
        }
        //printf("Found %I64d on %I64d\n", p[l], l + 1LL);
        if(p[l] <= k) {
            k += (l - lastk + 1);
            m -= (l - lastk + 1);
            lastk = l + 1;
            act++;
            // cout << "FIRST\n";
        }
        else {
           k = (p[lastk] + _k) - (p[lastk] % _k + 1);
        }
        // printf("Ended with %I64d and lastK = %I64d\n\n", l + 1LL, lastk);
    } cout << act;
}


#include <bits/stdc++.h>
#if !defined(ONLINE_JUDGE)
#include "prettyprint.hpp"
#endif

#define ent(smth) smth.begin(), smth.end()
#define fori(i,n) for(intel i = 0; i < n; i++)
#define forn(n) for(intel i = 0; i < n; ++i)
#define forx(i,x,n) for(intel i = x; i < n; i++)
#define iter_for(_cont, _iterator) for(auto _iterator  = _cont.begin(); _iterator != _cont.end(); ++_iterator)

using namespace std;
typedef long long intel;
typedef pair<int, int> pInt;
int main()
{
    intel n, m, k; cin >> n >> m >> k;
    intel _k = k, lastk = 0;
    vector<intel> p(m); for(auto &x : p) cin >> x;
    int act = 0;
    while(m > 0)
    {
        intel l = lastk, r = p.size() + 1;
        //printf("Search for %I64d\n", k);
        while(r - l > 1)
        {
            int mid = (r + l)/2;
            if(p[mid] <= k ) l = mid;
            else r = mid;
        }
       // printf("Found %I64d on %I64d\n", p[l], l + 1LL);
        if(p[l] <= k) {
           k += (l - lastk + 1);
           m -= (l - lastk + 1);
           lastk = l + 1;
           act++;
          // cout << "FIRST\n";
        }
        else
        {
            int j = (p[lastk] - 1) - (p[lastk] - 1) % _k;
           // cout << j << endl;
           if(p[lastk] - 1 % _k) j += _k;
            k = j;
        }
       // printf("Ended with %I64d and lastK = %I64d\n\n", l + 1LL, lastk);
    } cout << act;
}


#include <bits/stdc++.h>
#if !defined(ONLINE_JUDGE)
#include "prettyprint.hpp"
#endif

#define ent(smth) smth.begin(), smth.end()
#define fori(i,n) for(intel i = 0; i < n; i++)
#define forn(n) for(intel i = 0; i < n; ++i)
#define forx(i,x,n) for(intel i = x; i < n; i++)
#define iter_for(_cont, _iterator) for(auto _iterator  = _cont.begin(); _iterator != _cont.end(); ++_iterator)

using namespace std;
typedef long long intel;
typedef pair<int, int> pInt;
int main()
{
    intel n, m, k; cin >> n >> m >> k;
    intel _k = k, lastk = 0;
    vector<intel> p(m); for(auto &x : p) cin >> x;
    int act = 0;
    while(m > 0)
    {
        intel l = lastk, r = p.size() + 1;
         //printf("Search for %I64d\n", k);
        while(r - l > 1)
        {
            int mid = (r + l)/2;
            if(p[mid] <= k ) l = mid;
            else r = mid;
        }
        //printf("Found %I64d on %I64d\n", p[l], l + 1LL);
        if(p[l] <= k) {
            k += (l - lastk + 1);
            m -= (l - lastk + 1);
            lastk = l + 1;
            act++;
            // cout << "FIRST\n";
        }
        else {
           k = (p[lastk] + _k) - ((p[lastk]) % _k) + k%_k;
        }
        // printf("Ended with %I64d and lastK = %I64d\n\n", l + 1LL, lastk);
    } cout << act;
}


#include <bits/stdc++.h>
#if !defined(ONLINE_JUDGE)
#include "prettyprint.hpp"
#endif

#define ent(smth) smth.begin(), smth.end()
#define fori(i,n) for(intel i = 0; i < n; i++)
#define forn(n) for(intel i = 0; i < n; ++i)
#define forx(i,x,n) for(intel i = x; i < n; i++)
#define iter_for(_cont, _iterator) for(auto _iterator  = _cont.begin(); _iterator != _cont.end(); ++_iterator)

using namespace std;
typedef long long intel;
typedef pair<int, int> pInt;
int main()
{
    intel n, m, k; cin >> n >> m >> k;
    intel _k = k, lastk = 0;
    vector<intel> p(m); for(auto &x : p) cin >> x;
    int act = 0;
    while(m > 0)
    {
        intel l = lastk, r = p.size() + 1;
        // printf("Search for %I64d\n", k);
        while(r - l > 1)
        {
            int mid = (r + l)/2;
            if(p[mid] <= k ) l = mid;
            else r = mid;
        }
        //printf("Found %I64d on %I64d\n", p[l], l + 1LL);
        if(p[l] <= k) {
            k += (l - lastk + 1);
            m -= (l - lastk + 1);
            lastk = l + 1;
            act++;
            // cout << "FIRST\n";
        }
        else {
            k = k + ((p[lastk] - k) / _k + (p[lastk] - k) % _k);
        }
        // printf("Ended with %I64d and lastK = %I64d\n\n", l + 1LL, lastk);
    } cout << act;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)

const int L=1e6+7;
map<ll,ll> counter;
ll fastexpo(ll x,ll y,ll m)
{
	ll temp=1;
	while(y>0)
	{
		if(y&1)temp = ((temp%m)*(x%m))%m;
		x = ((x%m)*(x%m))%m;
		y>>=1;
	}return temp;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, m, k, sofar = 1, ans = 0;
	cin >> n >> m >> k;
	std::vector<ll> p(m);
	FOR(i,0,m)cin >> p[i];
	sort(all(p));
	ll it;
	// trace(p, x)
	while(!p.empty())
	{
		if(sofar>*p.begin())break;
		it = upper_bound(all(p), sofar + k-1) - lower_bound(all(p), sofar);
		sofar += it;
		// debug(it, sofar);
		if(it == 0)
		{
			// debug(sofar);
			sofar += ((*p.begin()-sofar)/k)*k;
			// debug(sofar);
		}
		else ans++;
		while(it--)p.erase(p.begin());
		// debug(sofar, *p.begin());
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
map<ll,ll> counter;
ll fastexpo(ll x,ll y,ll m)
{
	ll temp=1;
	while(y>0)
	{
		if(y&1)temp = ((temp%m)*(x%m))%m;
		x = ((x%m)*(x%m))%m;
		y>>=1;
	}return temp;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, m, k, sofar = 0, ans = 0;
	cin >> n >> m >> k;
	std::vector<ll> p(m);
	FOR(i,0,m)
	{
		cin >> p[i];
	}
	ll cur, it = 0, prv = 0;
	while(it < m)
	{
		cur = ((p[it]-sofar-1)/k)*k + sofar;
		while(it<m && p[it] <= cur + k)
		{
			// debug(p[it]);
			it++;
		}
		sofar += it;
		ans++;
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)

const int L=1e6+7;
map<ll,ll> counter;
ll fastexpo(ll x,ll y,ll m)
{
	ll temp=1;
	while(y>0)
	{
		if(y&1)temp = ((temp%m)*(x%m))%m;
		x = ((x%m)*(x%m))%m;
		y>>=1;
	}return temp;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, m, k, sofar = 0, ans = 0;
	cin >> n >> m >> k;
	std::vector<ll> p(m);
	FOR(i,0,m)cin >> p[i];
	// sort(all(p));
	ll it;
	// trace(p, x)
	while(1)
	{
		if(sofar>*p.rbegin())break;
		it = upper_bound(all(p), sofar + k) - lower_bound(all(p), sofar);
		sofar += it;
		// debug(it, sofar);
		if(it == 0)sofar += k;
		else ans++;
		while(it--)p.erase(p.begin());
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
map<ll,ll> counter;
ll fastexpo(ll x,ll y,ll m)
{
	ll temp=1;
	while(y>0)
	{
		if(y&1)temp = ((temp%m)*(x%m))%m;
		x = ((x%m)*(x%m))%m;
		y>>=1;
	}return temp;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, m, k, sofar = 1, ans = 0;
	cin >> n >> m >> k;
	ll x;
	pbds p;
	// std::vector<ll> p(m);
	FOR(i,0,m)
	{
		cin >> x;
		p.insert(x);
	}
	// sort(all(p));
	ll it;
	while(!p.empty())
	{
		// if(sofar>*p.begin())break;
		it = p.order_of_key(sofar + k) - p.order_of_key(sofar+1);
		sofar += it;
		if(it == 0)
		{
			sofar += ((*p.begin()-sofar)/k)*k;
		}
		else ans++;
		while(it--)p.erase(p.begin());
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)

const int L=1e6+7;
map<ll,ll> counter;
ll fastexpo(ll x,ll y,ll m)
{
	ll temp=1;
	while(y>0)
	{
		if(y&1)temp = ((temp%m)*(x%m))%m;
		x = ((x%m)*(x%m))%m;
		y>>=1;
	}return temp;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, m, k, sofar = 0, ans = 0;
	cin >> n >> m >> k;
	std::vector<ll> p(m);
	FOR(i,0,m)cin >> p[i];
	sort(all(p));
	ll it;
	// trace(p, x)
	while(!p.empty())
	{
		if(sofar>*p.begin())break;
		it = upper_bound(all(p), sofar + k) - lower_bound(all(p), sofar);
		sofar += it;
		// debug(it, sofar);
		if(it == 0)sofar += k;
		else ans++;
		while(it--)p.erase(p.begin());
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)

const int L=1e6+7;
map<ll,ll> counter;
ll fastexpo(ll x,ll y,ll m)
{
	ll temp=1;
	while(y>0)
	{
		if(y&1)temp = ((temp%m)*(x%m))%m;
		x = ((x%m)*(x%m))%m;
		y>>=1;
	}return temp;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, m, k, sofar = 0, ans = 0;
	cin >> n >> m >> k;
	std::vector<ll> p(m);
	FOR(i,0,m)cin >> p[i];
	sort(all(p));
	ll it;
	// trace(p, x)
	while(!p.empty())
	{
		if(sofar>*p.begin())break;
		it = upper_bound(all(p), sofar + k) - lower_bound(all(p), sofar);
		sofar += it;
		// debug(it, sofar);
		if(it == 0)
		{
			// debug(sofar);
			sofar = ((*p.begin()-sofar)/k)*k;
			// debug(sofar);
		}
		else ans++;
		while(it--)p.erase(p.begin());
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
map<ll,ll> counter;
ll fastexpo(ll x,ll y,ll m)
{
	ll temp=1;
	while(y>0)
	{
		if(y&1)temp = ((temp%m)*(x%m))%m;
		x = ((x%m)*(x%m))%m;
		y>>=1;
	}return temp;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, m, k, sofar = 0, ans = 0;
	cin >> n >> m >> k;
	std::vector<ll> p(m);
	FOR(i,0,m)
	{
		cin >> p[i];
	}
	ll cur, it = 0, prv = 0;
	while(it < m)
	{
		cur = ((p[it]-sofar-1)/k)*k + sofar;
		while(it<m && p[it] <= cur + k)
		{
			sofar++;
			it++;
		}
		ans++;
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
map<ll,ll> counter;
ll fastexpo(ll x,ll y,ll m)
{
	ll temp=1;
	while(y>0)
	{
		if(y&1)temp = ((temp%m)*(x%m))%m;
		x = ((x%m)*(x%m))%m;
		y>>=1;
	}return temp;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, m, k, sofar = 0, ans = 0;
	cin >> n >> m >> k;
	std::vector<ll> p(m);
	FOR(i,0,m)
	{
		cin >> p[i];
		p[i]--;
	}
	ll cur, it = 0, prv = 0;
	while(it < m)
	{
		cur = ((p[it]-sofar)/k)*k + sofar;
		while(it<m && p[it] <= cur + k)
		{
			// debug(p[it]);
			it++;
		}
		sofar += it;
		ans++;
	}
	cout<<ans;
	return 0;
}


#include <iostream>
#include <algorithm>

#define fu(i,a,b) for(int i=a ; i<=b ; i++)
#define fd(i,a,n) for(int i=a ; i>=b ; i--)
#define ll long long

using namespace std;

const ll M=1e18;
int m,k,a[100001],de,res;
ll n;

int main()
{
    cin >> n >> m >> k;
    int k2=k,mark=0;
    fu(i,1,m) cin >> a[i];
    fu(i,1,m){
    	a[i]-=de;
    	//cout << a[i] << " ";
    	if(a[i]<=k2 && a[i+1]-de>k2){
			de=i;
			if(a[i+1]-de>k2) k2+=k;
			res++;
			mark=i;
			//cout << res <<" "<< k2 <<" ";
    	}
    }
    if(mark!=m) res++;
    cout << res;
    return 0;
}


#include <iostream>
#include <algorithm>

#define fu(i,a,b) for(int i=a ; i<=b ; i++)
#define fd(i,a,n) for(int i=a ; i>=b ; i--)
#define ll long long

using namespace std;

const ll M=1e18;
int m;
ll n,mark,a[100002],k,de,res;

int main()
{
    cin >> n >> m >> k;
    fu(i,1,m) cin >> a[i];
    int k2=(a[1]/k+1)*k;
    fu(i,1,m){
    	a[i]-=de;
    	//cout << a[i] << " ";
    	if(a[i]<=k2 && a[i+1]-de>k2){
			de=i;
			k2=(a[i+1]-de)/k*k;
			if(a[i+1]-de>k2) k2=((a[i+1]-de)/k+1)*k;
			res++;
			mark=i;
			cout << de << endl;
			//cout << res <<" "<< k2 <<endl;
    	}
    }
    if(mark!=m) res++;
    cout << res;
    return 0;
}
/*1000000000000000000 10 100
2 4 6 8 10 12 14 16 18 20
1*/


#include <iostream>
#include <algorithm>

#define fu(i,a,b) for(int i=a ; i<=b ; i++)
#define fd(i,a,n) for(int i=a ; i>=b ; i--)
#define ll long long

using namespace std;

const ll M=1e18;
int m;
ll n,mark,a[100002],k,de,res;

int main()
{
    cin >> n >> m >> k;
    int k2=k;
    fu(i,1,m) cin >> a[i];
    fu(i,1,m){
    	a[i]-=de;
    	//cout << a[i] << " ";
    	if(a[i]<=k2 && a[i+1]-de>k2){
			de=i;
			if(a[i+1]-de>k2) k2+=k;
			res++;
			mark=i;
			//cout << res <<" "<< k2 <<" ";
    	}
    	while(a[i]>k2) k2+=k;
    }
    if(mark!=m) res++;
    cout << res;
    return 0;
}


#include <iostream>
#include <algorithm>

#define fu(i,a,b) for(int i=a ; i<=b ; i++)
#define fd(i,a,n) for(int i=a ; i>=b ; i--)
#define ll long long

using namespace std;

const ll M=1e18;
int n,m,k,a[100001],de,res;

int main()
{
    cin >> n >> m >> k;
    int k2=k,mark=0;
    fu(i,1,m) cin >> a[i];
    fu(i,1,m){
    	a[i]-=de;
    	//cout << a[i] << " ";
    	if(a[i]<=k2 && a[i+1]-de>k2){
			de=i;
			if(a[i+1]-de>k2) k2+=k;
			res++;
			mark=i;
			//cout << res <<" "<< k2 <<" ";
    	}
    }
    if(mark!=m) res++;
    cout << res;
    return 0;
}


#include <iostream>
#include <algorithm>

#define fu(i,a,b) for(int i=a ; i<=b ; i++)
#define fd(i,a,n) for(int i=a ; i>=b ; i--)
#define ll long long

using namespace std;

const ll M=1e18;
int m;
ll n,mark,a[100002],k,de,res;

int main()
{
    cin >> n >> m >> k;
    int k2=k;
    fu(i,1,m) cin >> a[i];
    fu(i,1,m){
    	a[i]-=de;
    	//cout << a[i] << " ";
    	if(a[i]<=k2 && a[i+1]-de>k2){
			de=i;
			if(a[i+1]-de>k2) k2+=k;
			res++;
			mark=i;
			//cout << res <<" "<< k2 <<" ";
    	}
    }
    if(mark!=m) res++;
    cout << res;
    return 0;
}


#include <iostream>
#include <algorithm>

#define fu(i,a,b) for(int i=a ; i<=b ; i++)
#define fd(i,a,n) for(int i=a ; i>=b ; i--)
#define ll long long

using namespace std;

const ll M=1e18;
int m;
ll n,mark,a[100002],k,de,res;

int main()
{
    cin >> n >> m >> k;
    int k2=k;
    fu(i,1,m) cin >> a[i];
    fu(i,1,m){
    	a[i]-=de;
    	//cout << a[i] << " ";
    	if(a[i]<=k2 && a[i+1]-de>k2){
			de=i;
			if(a[i+1]-de>k2) k2=(a[i+1]-de)/k+1;
			res++;
			mark=i;
			//cout << res <<" "<< k2 <<" ";
    	}
    }
    if(mark!=m) res++;
    cout << res;
    return 0;
}
/*1000000000000000000 10 100
2 4 6 8 10 12 14 16 18 20
1*/


#include <iostream>
#include <algorithm>

#define fu(i,a,b) for(int i=a ; i<=b ; i++)
#define fd(i,a,n) for(int i=a ; i>=b ; i--)
#define ll long long

using namespace std;

const ll M=1e18;
int m,k,de,res;
ll n,mark,a[100001];

int main()
{
    cin >> n >> m >> k;
    int k2=k;
    fu(i,1,m) cin >> a[i];
    fu(i,1,m){
    	a[i]-=de;
    	//cout << a[i] << " ";
    	if(a[i]<=k2 && a[i+1]-de>k2){
			de=i;
			if(a[i+1]-de>k2) k2+=k;
			res++;
			mark=i;
			//cout << res <<" "<< k2 <<" ";
    	}
    }
    if(mark!=m) res++;
    cout << res;
    return 0;
}


#include <iostream>
#include <algorithm>

#define fu(i,a,b) for(int i=a ; i<=b ; i++)
#define fd(i,a,n) for(int i=a ; i>=b ; i--)
#define ll long long

using namespace std;

const ll M=1e18;
int m;
ll n,mark,a[100002],k,de,res;

int main()
{
    cin >> n >> m >> k;
    fu(i,1,m) cin >> a[i];
    int k2=(a[1]/k+1)*k;
    fu(i,1,m){
    	a[i]-=de;
    	//cout << a[i] << " ";
    	if(a[i]<=k2 && a[i+1]-de>k2){
			de=i;
			k2=(a[i+1]-de)/k*k;
			if(a[i+1]-de>k2) k2=((a[i+1]-de)/k+1)*k;
			res++;
			mark=i;
			//cout << de << endl;
			//cout << res <<" "<< k2 <<endl;
    	}
    }
    if(mark!=m) res++;
    cout << res;
    return 0;
}
/*1000000000000000000 10 100
2 4 6 8 10 12 14 16 18 20
1*/


#include <iostream>
#include <algorithm>

#define fu(i,a,b) for(int i=a ; i<=b ; i++)
#define fd(i,a,n) for(int i=a ; i>=b ; i--)
#define ll long long

using namespace std;

const ll M=1e18;
int m,k,de,res;
ll n,mark,a[100002];

int main()
{
    cin >> n >> m >> k;
    int k2=k;
    fu(i,1,m) cin >> a[i];
    fu(i,1,m){
    	a[i]-=de;
    	//cout << a[i] << " ";
    	if(a[i]<=k2 && a[i+1]-de>k2){
			de=i;
			if(a[i+1]-de>k2) k2+=k;
			res++;
			mark=i;
			//cout << res <<" "<< k2 <<" ";
    	}
    }
    if(mark!=m) res++;
    cout << res;
    return 0;
}


#include <iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
using namespace std;
const int INF = 0x3f3f3f3f;
long long a[100050];
long long  n,m,k;
int cmp(long long a,long long b){
	return a<b;
}
int main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	long long ans=0;
	for(long long i=1;i<=m;i++){
		scanf("%lld",&a[i]);
	}
	long long l=0;
	long long t;
	long long  i=1;
	while(i<=m){
		t=0;
		long long page=(a[i]-1-l)/k+1;
		ans++;
		while(a[i]-l<=page*k){
			i++;
			t++;
			if(i>m) break;
		}
		l+=t;
	}
	printf("%lld",ans);
}


#include <iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
using namespace std;
const int INF = 0x3f3f3f3f;
long long a[100010];
long long  n,m,k;
int cmp(long long a,long long b){
	return a<b;
}
int main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	long long ans=0;
	for(long long i=1;i<=m;i++){
		scanf("%lld",&a[i]);
	}
	//sort(a+1,a+m+1,cmp);
	long long ktmp=k;
	int vis[100010];
	memset(vis,0,sizeof(vis));
	for(long long i=1;i<=m;i++){
		if(a[i]>k&&!vis[i]){
			vis[i]=1;
			if(i==1){
				printf("1");
				return 0;
			}
			ans++;
			k=ktmp+i-1;
			i--;
		}else if(a[i]>k&&vis[i]){
			ans++;
			break;
		}else if(i==m){
			ans++;
		}
	}
	printf("%lld",ans);
}


#include <iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
using namespace std;
const int INF = 0x3f3f3f3f;
long long a[100010];
long long  n,m,k;
int main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	int ans=0;
	for(int i=1;i<=m;i++){
		scanf("%lld",&a[i]);
	}
	long long ind=upper_bound(a+1,a+m+1,k)-a-1;
	if(ind==0){
		printf("1");
		return 0;
	}
	ans++;
	long long ktmp=k;
	while(ind<m){
		k=ktmp+ind;
		long long tmp=ind;
		ind=upper_bound(a+tmp,a+m+1,k)-a-1;
		if(ind==tmp){
			ans++;
			break;
		}else{
			ans++;
		}
	}
	printf("%d",ans);
}


#include <iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
using namespace std;
const int INF = 0x3f3f3f3f;
long long a[100010];
long long  n,m,k;
int cmp(long long a,long long b){
	return a<b;
}
int main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	long long ans=0;
	for(long long i=1;i<=m;i++){
		scanf("%lld",&a[i]);
	}
	//sort(a+1,a+m+1,cmp);
	long long ktmp=k;
	int vis[100010];
	memset(vis,0,sizeof(vis));
	for(long long i=1;i<=m;i++){
		if(a[i]>k&&!vis[i]){
			vis[i]=1;
			if(i==1){
				printf("1");
				return 0;
			}
			ans++;
			k=ktmp+i-1;
			i--;
		}else if(a[i]>k&&vis[i]){
			ans++;
			break;
		}
	}
	printf("%lld",ans);
}


#include <iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
using namespace std;
const int INF = 0x3f3f3f3f;
long long a[100010];
long long  n,m,k;
int cmp(long long a,long long b){
	return a<b;
}
int main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	int ans=0;
	for(int i=1;i<=m;i++){
		scanf("%lld",&a[i]);
	}
	long long ind=upper_bound(a+1,a+m+1,k,cmp)-a-1;
	if(ind==0){
		printf("1");
		return 0;
	}
	ans++;
	long long ktmp=k;
	while(ind<m){
		k=ktmp+ind;
		long long tmp=ind;
		ind=upper_bound(a+tmp,a+m+1,k,cmp)-a-1;
		if(ind==tmp){
			ans++;
			break;
		}else{
			ans++;
		}
	}
	printf("%d",ans);
}


#include <iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
using namespace std;
const int INF = 0x3f3f3f3f;
long long a[100010];
long long  n,m,k;
int main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	int ans=0;
	for(int i=1;i<=m;i++){
		scanf("%d",&a[i]);
	}
	int ind=upper_bound(a+1,a+m+1,k)-a-1;
	if(ind==0){
		printf("1");
		return 0;
	}
	ans++;
	while(ind<m){
		k+=ind;
		int tmp=ind;
		ind=upper_bound(a+tmp,a+m+1,k)-a-1;
		if(ind==tmp){
			ans++;
			break;
		}else{
			ans++;
		}
	}
	printf("%d",ans);
}


#include <iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
using namespace std;
const int INF = 0x3f3f3f3f;
long long a[100010];
long long  n,m,k;
int cmp(long long a,long long b){
	return a<b;
}
int main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	long long ans=0;
	for(long long i=1;i<=m;i++){
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+m+1,cmp);
	long long ind=upper_bound(a+1,a+m+1,k,cmp)-a-1;
	if(ind==0){
		printf("1");
		return 0;
	}
	ans++;
	long long ktmp=k;
	while(ind<m){
		k=ktmp+ind;
		long long tmp=ind;
		ind=upper_bound(a+tmp,a+m+1,k,cmp)-a-1;
		if(ind==tmp){
			ans++;
			break;
		}else{
			ans++;
		}
	}
	printf("%lld",ans);
}


#include <iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
using namespace std;
const int INF = 0x3f3f3f3f;
long long a[100010];
long long  n,m,k;
int cmp(long long a,long long b){
	return a<b;
}
int main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	long long ans=0;
	for(long long i=1;i<=m;i++){
		scanf("%lld",&a[i]);
	}
	//sort(a+1,a+m+1,cmp);
	long long ktmp=k;
	for(long long i=1;i<=m;i++){
		if(a[i]>k){
			if(i==1){
				printf("1");
				return 0;
			}
			ans++;
			int tmp=k;
			k=ktmp+i-1;
			if(k==tmp) break;
			i--;
		}
	}
	printf("%lld",ans);
}


/******************************************************/
/******************************************************/
/**            BISMILLAHIR RAHMANIR RAHIM            **/
/**         Al-Shahriar Tonmoy - Red_Sparkle         **/
/**  Department of Computer Science and Engineering  **/
/**               Barisal University                 **/
/**               It's time to bloom.                **/
/******************************************************/
/******************************************************/

#include<bits/stdc++.h>
using namespace std;
#define     fRead           freopen("input.txt","r",stdin)
#define     fWrite          freopen("output.txt","w",stdout)
#define     fast            ios_base::sync_with_stdio(false);cin.tie(NULL)
#define     in1(X)          scanf("%lli",&(X))
#define     in2(X,Y)        scanf("%lli%lli",&(X),&(Y))
#define     in3(X,Y,Z)      scanf("%lli%lli%lli",&(X),&(Y),&(Z))
#define     ins(S)          scanf("%s",(S))
#define     out(X)          printf("%lli",(X))
#define     outs(S)         printf("%s",(S))
#define     printnl         printf("\n")
#define     printsp         printf(" ");
#define     End             return 0
#define     ll              long long int
#define     ul              unsigned long long int
#define     dob             double
#define     st              string
#define     pairl           pair<ll,ll>
#define     max3(a,b,c)     max(a,max(b,c))
#define     min3(a,b,c)     min(a,min(b,c))
#define     fr              first
#define     se              second
#define     T               true
#define     F               false
#define     nl              "\n"
#define     all(v)          v.begin(),v.end()
#define     mem(a,v)        memset(a,v,sizeof(a))
#define     maxi            1000000000000000014
#define     mini            -100000000000014
#define     mod             1000000007
#define     an              1000007
#define     mapi            map<ll,ll>
#define     pi              push_back
#define     po              pop_back
#define     ve              vector<ll>
#define     mp              make_pair
#define     PI              3.14159265

/*************** #Template FUNCTIONS# **************/

/// ll pc;void PrintCase(){printf("Case %lli: ",++pc);}
/// ll GCD(ll a,ll b){if(a<0) a*=-1;if(b<0) b*=-1;if(a<b)swap(a,b);if(b==1) return 1;if(!b) return a;if(!(a%b)) return b;else return GCD(b,a%b);}
/// ll LCM(ll a,ll b){ll x=GCD(a,b);return (a/x)*b;}
/// ll bigmod(ll n,ll p){if(p==0) return 1;if(p==1)return (n+mod)%mod;if(p%2)return (bigmod(n,p-1)*n+mod)%mod;else{ll x=bigmod(n,p/2);return (x*x+mod)%mod;}}
/// ll modinverse(ll n){return bigmod(n,mod-2)%mod;}
/// bool sc[an];ve pr;void sieve(){for(ll i=2;i*i<an;i++){if(!sc[i]){for(ll j=i*i;j<an;j+=i) sc[j]=1;}}pr.pi(2);for(ll i=3;i<an;i+=2) if(!sc[i]) pr.pi(i);}
/// pairl pf[an];void pri_fact(ll n){ll i,u=0;for(i=0;i<pr.size() && n!=1;i++){ll c=0;while(!(n%pr[i])){n/=pr[i];c++;} if(c){pf[u].fr=pr[i];pf[u].se=c;u++;}}if(n>1){pf[u].fr=n;pf[u].se=1;}}
/// ve de;void devisors(ll n){ll i;for(i=1;i<=sqrt(n);i++){if(!(n%i) && i!=sqrt(n)){de.pi(i);de.pi(n%i);}}if((i-1)*(i-1)==n) de.pi(i-1);sort(all(de));}

/********************** START **********************/

int main()
{

    ll n,m,k;
    scanf("%lli %lli %lli",&n,&m,&k);

    ll a[m],i;
    for(i=0;i<m;i++){
    	scanf("%lli",&a[i]);
    }

    i=0;ll p=(a[i]/k+(a[i]%k?1:0))*k,ans=0,c=0,s=0;

    while(p<=a[m-1]+k){
    	for(c=0;i<m;i++){
    		if(a[i]-s<=p){
    			c++;
    		}
    		else break;
    	}
    	s+=c;
    	if(c) ans++;
    	else p=((a[i]-s)/k+((a[i]-s)%k?1:0))*k;
    }

    printf("%lli\n",ans);

    End;
}
/*****************  ALHAMDULILLAH  *****************/


/******************************************************/
/******************************************************/
/**            BISMILLAHIR RAHMANIR RAHIM            **/
/**         Al-Shahriar Tonmoy - Red_Sparkle         **/
/**  Department of Computer Science and Engineering  **/
/**               Barisal University                 **/
/**               It's time to bloom.                **/
/******************************************************/
/******************************************************/

#include<bits/stdc++.h>
using namespace std;
#define     fRead           freopen("input.txt","r",stdin)
#define     fWrite          freopen("output.txt","w",stdout)
#define     fast            ios_base::sync_with_stdio(false);cin.tie(NULL)
#define     in1(X)          scanf("%lli",&(X))
#define     in2(X,Y)        scanf("%lli%lli",&(X),&(Y))
#define     in3(X,Y,Z)      scanf("%lli%lli%lli",&(X),&(Y),&(Z))
#define     ins(S)          scanf("%s",(S))
#define     out(X)          printf("%lli",(X))
#define     outs(S)         printf("%s",(S))
#define     printnl         printf("\n")
#define     printsp         printf(" ");
#define     End             return 0
#define     ll              long long int
#define     ul              unsigned long long int
#define     dob             double
#define     st              string
#define     pairl           pair<ll,ll>
#define     max3(a,b,c)     max(a,max(b,c))
#define     min3(a,b,c)     min(a,min(b,c))
#define     fr              first
#define     se              second
#define     T               true
#define     F               false
#define     nl              "\n"
#define     all(v)          v.begin(),v.end()
#define     mem(a,v)        memset(a,v,sizeof(a))
#define     maxi            1000000000000000014
#define     mini            -100000000000014
#define     mod             1000000007
#define     an              1000007
#define     mapi            map<ll,ll>
#define     pi              push_back
#define     po              pop_back
#define     ve              vector<ll>
#define     mp              make_pair
#define     PI              3.14159265

/*************** #Template FUNCTIONS# **************/

/// ll pc;void PrintCase(){printf("Case %lli: ",++pc);}
/// ll GCD(ll a,ll b){if(a<0) a*=-1;if(b<0) b*=-1;if(a<b)swap(a,b);if(b==1) return 1;if(!b) return a;if(!(a%b)) return b;else return GCD(b,a%b);}
/// ll LCM(ll a,ll b){ll x=GCD(a,b);return (a/x)*b;}
/// ll bigmod(ll n,ll p){if(p==0) return 1;if(p==1)return (n+mod)%mod;if(p%2)return (bigmod(n,p-1)*n+mod)%mod;else{ll x=bigmod(n,p/2);return (x*x+mod)%mod;}}
/// ll modinverse(ll n){return bigmod(n,mod-2)%mod;}
/// bool sc[an];ve pr;void sieve(){for(ll i=2;i*i<an;i++){if(!sc[i]){for(ll j=i*i;j<an;j+=i) sc[j]=1;}}pr.pi(2);for(ll i=3;i<an;i+=2) if(!sc[i]) pr.pi(i);}
/// pairl pf[an];void pri_fact(ll n){ll i,u=0;for(i=0;i<pr.size() && n!=1;i++){ll c=0;while(!(n%pr[i])){n/=pr[i];c++;} if(c){pf[u].fr=pr[i];pf[u].se=c;u++;}}if(n>1){pf[u].fr=n;pf[u].se=1;}}
/// ve de;void devisors(ll n){ll i;for(i=1;i<=sqrt(n);i++){if(!(n%i) && i!=sqrt(n)){de.pi(i);de.pi(n%i);}}if((i-1)*(i-1)==n) de.pi(i-1);sort(all(de));}

/********************** START **********************/

int main()
{

    fast;

    ll n,m,k;
    cin>>n>>m>>k;

    ll a[m],i;
    for(i=0;i<m;i++){
    	cin>>a[i];
    }

    i=0;ll p=(a[i]/k+(a[i]<k?1:0))*k,ans=0,c=0,s=0;

    while(p<=a[m-1]+k){
    	for(c=0;i<m;i++){
    		if(a[i]-s<=p){
    			c++;
    		}
    		else break;
    	}
    	s+=c;
    	if(c) ans++;
    	else p+=((a[i]-s)/k+(a[i]-s<k?1:0))*k;
    }

    cout<<ans<<endl;

    End;
}
/*****************  ALHAMDULILLAH  *****************/


/******************************************************/
/******************************************************/
/**            BISMILLAHIR RAHMANIR RAHIM            **/
/**         Al-Shahriar Tonmoy - Red_Sparkle         **/
/**  Department of Computer Science and Engineering  **/
/**               Barisal University                 **/
/**               It's time to bloom.                **/
/******************************************************/
/******************************************************/

#include<bits/stdc++.h>
using namespace std;
#define     fRead           freopen("input.txt","r",stdin)
#define     fWrite          freopen("output.txt","w",stdout)
#define     fast            ios_base::sync_with_stdio(false);cin.tie(NULL)
#define     in1(X)          scanf("%lli",&(X))
#define     in2(X,Y)        scanf("%lli%lli",&(X),&(Y))
#define     in3(X,Y,Z)      scanf("%lli%lli%lli",&(X),&(Y),&(Z))
#define     ins(S)          scanf("%s",(S))
#define     out(X)          printf("%lli",(X))
#define     outs(S)         printf("%s",(S))
#define     printnl         printf("\n")
#define     printsp         printf(" ");
#define     End             return 0
#define     ll              long long int
#define     ul              unsigned long long int
#define     dob             double
#define     st              string
#define     pairl           pair<ll,ll>
#define     max3(a,b,c)     max(a,max(b,c))
#define     min3(a,b,c)     min(a,min(b,c))
#define     fr              first
#define     se              second
#define     T               true
#define     F               false
#define     nl              "\n"
#define     all(v)          v.begin(),v.end()
#define     mem(a,v)        memset(a,v,sizeof(a))
#define     maxi            1000000000000000014
#define     mini            -100000000000014
#define     mod             1000000007
#define     an              1000007
#define     mapi            map<ll,ll>
#define     pi              push_back
#define     po              pop_back
#define     ve              vector<ll>
#define     mp              make_pair
#define     PI              3.14159265

/*************** #Template FUNCTIONS# **************/

/// ll pc;void PrintCase(){printf("Case %lli: ",++pc);}
/// ll GCD(ll a,ll b){if(a<0) a*=-1;if(b<0) b*=-1;if(a<b)swap(a,b);if(b==1) return 1;if(!b) return a;if(!(a%b)) return b;else return GCD(b,a%b);}
/// ll LCM(ll a,ll b){ll x=GCD(a,b);return (a/x)*b;}
/// ll bigmod(ll n,ll p){if(p==0) return 1;if(p==1)return (n+mod)%mod;if(p%2)return (bigmod(n,p-1)*n+mod)%mod;else{ll x=bigmod(n,p/2);return (x*x+mod)%mod;}}
/// ll modinverse(ll n){return bigmod(n,mod-2)%mod;}
/// bool sc[an];ve pr;void sieve(){for(ll i=2;i*i<an;i++){if(!sc[i]){for(ll j=i*i;j<an;j+=i) sc[j]=1;}}pr.pi(2);for(ll i=3;i<an;i+=2) if(!sc[i]) pr.pi(i);}
/// pairl pf[an];void pri_fact(ll n){ll i,u=0;for(i=0;i<pr.size() && n!=1;i++){ll c=0;while(!(n%pr[i])){n/=pr[i];c++;} if(c){pf[u].fr=pr[i];pf[u].se=c;u++;}}if(n>1){pf[u].fr=n;pf[u].se=1;}}
/// ve de;void devisors(ll n){ll i;for(i=1;i<=sqrt(n);i++){if(!(n%i) && i!=sqrt(n)){de.pi(i);de.pi(n%i);}}if((i-1)*(i-1)==n) de.pi(i-1);sort(all(de));}

/********************** START **********************/

int main()
{

    fast;

    ll n,m,k;
    cin>>n>>m>>k;

    ll a[m],i;
    for(i=0;i<m;i++){
    	cin>>a[i];
    }

    ll p=k,ans=0,c=0,s=0;i=0;

    while(p<=a[m-1]+k){
    	for(c=0;i<m;i++){
    		if(a[i]-s<=p){
    			c++;
    		}
    		else break;
    	}
    	if(c) ans++;
    	else p+=k;
    	s+=c;
    }

    cout<<ans<<endl;

    End;
}
/*****************  ALHAMDULILLAH  *****************/


/******************************************************/
/******************************************************/
/**            BISMILLAHIR RAHMANIR RAHIM            **/
/**         Al-Shahriar Tonmoy - Red_Sparkle         **/
/**  Department of Computer Science and Engineering  **/
/**               Barisal University                 **/
/**               It's time to bloom.                **/
/******************************************************/
/******************************************************/

#include<bits/stdc++.h>
using namespace std;
#define     fRead           freopen("input.txt","r",stdin)
#define     fWrite          freopen("output.txt","w",stdout)
#define     fast            ios_base::sync_with_stdio(false);cin.tie(NULL)
#define     in1(X)          scanf("%lli",&(X))
#define     in2(X,Y)        scanf("%lli%lli",&(X),&(Y))
#define     in3(X,Y,Z)      scanf("%lli%lli%lli",&(X),&(Y),&(Z))
#define     ins(S)          scanf("%s",(S))
#define     out(X)          printf("%lli",(X))
#define     outs(S)         printf("%s",(S))
#define     printnl         printf("\n")
#define     printsp         printf(" ");
#define     End             return 0
#define     ll              long long int
#define     ul              unsigned long long int
#define     dob             double
#define     st              string
#define     pairl           pair<ll,ll>
#define     max3(a,b,c)     max(a,max(b,c))
#define     min3(a,b,c)     min(a,min(b,c))
#define     fr              first
#define     se              second
#define     T               true
#define     F               false
#define     nl              "\n"
#define     all(v)          v.begin(),v.end()
#define     mem(a,v)        memset(a,v,sizeof(a))
#define     maxi            1000000000000000014
#define     mini            -100000000000014
#define     mod             1000000007
#define     an              1000007
#define     mapi            map<ll,ll>
#define     pi              push_back
#define     po              pop_back
#define     ve              vector<ll>
#define     mp              make_pair
#define     PI              3.14159265

/*************** #Template FUNCTIONS# **************/

/// ll pc;void PrintCase(){printf("Case %lli: ",++pc);}
/// ll GCD(ll a,ll b){if(a<0) a*=-1;if(b<0) b*=-1;if(a<b)swap(a,b);if(b==1) return 1;if(!b) return a;if(!(a%b)) return b;else return GCD(b,a%b);}
/// ll LCM(ll a,ll b){ll x=GCD(a,b);return (a/x)*b;}
/// ll bigmod(ll n,ll p){if(p==0) return 1;if(p==1)return (n+mod)%mod;if(p%2)return (bigmod(n,p-1)*n+mod)%mod;else{ll x=bigmod(n,p/2);return (x*x+mod)%mod;}}
/// ll modinverse(ll n){return bigmod(n,mod-2)%mod;}
/// bool sc[an];ve pr;void sieve(){for(ll i=2;i*i<an;i++){if(!sc[i]){for(ll j=i*i;j<an;j+=i) sc[j]=1;}}pr.pi(2);for(ll i=3;i<an;i+=2) if(!sc[i]) pr.pi(i);}
/// pairl pf[an];void pri_fact(ll n){ll i,u=0;for(i=0;i<pr.size() && n!=1;i++){ll c=0;while(!(n%pr[i])){n/=pr[i];c++;} if(c){pf[u].fr=pr[i];pf[u].se=c;u++;}}if(n>1){pf[u].fr=n;pf[u].se=1;}}
/// ve de;void devisors(ll n){ll i;for(i=1;i<=sqrt(n);i++){if(!(n%i) && i!=sqrt(n)){de.pi(i);de.pi(n%i);}}if((i-1)*(i-1)==n) de.pi(i-1);sort(all(de));}

/********************** START **********************/

int main()
{

    fast;

    ll n,m,k;
    cin>>n>>m>>k;

    ll a[m],i;
    for(i=0;i<m;i++){
    	cin>>a[i];
    }

    i=0;ll p=(a[i]/k+(a[i]%k?1:0))*k,ans=0,c=0,s=0;

    while(p<=a[m-1]+k){
    	for(c=0;i<m;i++){
    		if(a[i]-s<=p){
    			c++;
    		}
    		else break;
    	}
    	s+=c;
    	if(c) ans++;
    	else p+=((a[i]-s)/k+((a[i]-s)%k?1:0))*k;
    }

    cout<<ans<<endl;

    End;
}
/*****************  ALHAMDULILLAH  *****************/


/******************************************************/
/******************************************************/
/**            BISMILLAHIR RAHMANIR RAHIM            **/
/**         Al-Shahriar Tonmoy - Red_Sparkle         **/
/**  Department of Computer Science and Engineering  **/
/**               Barisal University                 **/
/**               It's time to bloom.                **/
/******************************************************/
/******************************************************/

#include<bits/stdc++.h>
using namespace std;
#define     fRead           freopen("input.txt","r",stdin)
#define     fWrite          freopen("output.txt","w",stdout)
#define     fast            ios_base::sync_with_stdio(false);cin.tie(NULL)
#define     in1(X)          scanf("%lli",&(X))
#define     in2(X,Y)        scanf("%lli%lli",&(X),&(Y))
#define     in3(X,Y,Z)      scanf("%lli%lli%lli",&(X),&(Y),&(Z))
#define     ins(S)          scanf("%s",(S))
#define     out(X)          printf("%lli",(X))
#define     outs(S)         printf("%s",(S))
#define     printnl         printf("\n")
#define     printsp         printf(" ");
#define     End             return 0
#define     ll              long long int
#define     ul              unsigned long long int
#define     dob             double
#define     st              string
#define     pairl           pair<ll,ll>
#define     max3(a,b,c)     max(a,max(b,c))
#define     min3(a,b,c)     min(a,min(b,c))
#define     fr              first
#define     se              second
#define     T               true
#define     F               false
#define     nl              "\n"
#define     all(v)          v.begin(),v.end()
#define     mem(a,v)        memset(a,v,sizeof(a))
#define     maxi            1000000000000000014
#define     mini            -100000000000014
#define     mod             1000000007
#define     an              1000007
#define     mapi            map<ll,ll>
#define     pi              push_back
#define     po              pop_back
#define     ve              vector<ll>
#define     mp              make_pair
#define     PI              3.14159265

/*************** #Template FUNCTIONS# **************/

/// ll pc;void PrintCase(){printf("Case %lli: ",++pc);}
/// ll GCD(ll a,ll b){if(a<0) a*=-1;if(b<0) b*=-1;if(a<b)swap(a,b);if(b==1) return 1;if(!b) return a;if(!(a%b)) return b;else return GCD(b,a%b);}
/// ll LCM(ll a,ll b){ll x=GCD(a,b);return (a/x)*b;}
/// ll bigmod(ll n,ll p){if(p==0) return 1;if(p==1)return (n+mod)%mod;if(p%2)return (bigmod(n,p-1)*n+mod)%mod;else{ll x=bigmod(n,p/2);return (x*x+mod)%mod;}}
/// ll modinverse(ll n){return bigmod(n,mod-2)%mod;}
/// bool sc[an];ve pr;void sieve(){for(ll i=2;i*i<an;i++){if(!sc[i]){for(ll j=i*i;j<an;j+=i) sc[j]=1;}}pr.pi(2);for(ll i=3;i<an;i+=2) if(!sc[i]) pr.pi(i);}
/// pairl pf[an];void pri_fact(ll n){ll i,u=0;for(i=0;i<pr.size() && n!=1;i++){ll c=0;while(!(n%pr[i])){n/=pr[i];c++;} if(c){pf[u].fr=pr[i];pf[u].se=c;u++;}}if(n>1){pf[u].fr=n;pf[u].se=1;}}
/// ve de;void devisors(ll n){ll i;for(i=1;i<=sqrt(n);i++){if(!(n%i) && i!=sqrt(n)){de.pi(i);de.pi(n%i);}}if((i-1)*(i-1)==n) de.pi(i-1);sort(all(de));}

/********************** START **********************/

int main()
{

    fast;

    ll n,m,k;
    cin>>n>>m>>k;

    ll a[m],i;
    for(i=0;i<m;i++){
    	cin>>a[i];
    }

    i=0;ll p=(a[i]/k+(a[i]%k?1:0))*k,ans=0,c=0,s=0;

    while(p<=a[m-1]+k){
    	for(c=0;i<m;i++){
    		if(a[i]-s<=p){
    			c++;
    		}
    		else break;
    	}
    	s+=c;
    	if(c) ans++;
    	else p=((a[i]-s)/k+((a[i]-s)%k?1:0))*k;
    }

    cout<<ans<<endl;

    End;
}
/*****************  ALHAMDULILLAH  *****************/