#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;

long long a[100005];

int main()
{
  long long n;
  int m, k;
  scanf("%lld%d%d", &n, &m, &k);
  for (int i = 1; i <= m; i++)
  {
    scanf("%lld", &a[i]);
    a[i]--;
  }
  int i = 1;
  int now = 0;
  int ans = 0;
  while (i <= m)
  {
    int t = (a[i] - now) / k;
    ans++;
    while ((a[i + 1] - now) / k == t && i < m)
      i++;
    now = i;
    i++;
  }
  printf("%d\n", ans);
  return 0;
}


#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;

long long a[100005];

int main()
{
  long long n;
  int m, k;
  scanf("%lld%d%d", &n, &m, &k);
  for (int i = 1; i <= m; i++)
  {
    scanf("%lld", &a[i]);
    a[i]--;
  }
  int i = 1;
  int now = 0;
  int ans = 0;
  while (i <= m)
  {
    int t = (a[i] - now) / k;
    ans++;
    while ((a[i + 1] - now) / k == t && i < n)
      i++;
    now = i;
    i++;
  }
  printf("%d\n", ans);
  return 0;
}


#include <bits/stdc++.h>
#define LL long long

using namespace std;

const int N = 101110;
LL A[N], k;
LL n;
int ans, m;

int main() {
    //freopen("TASK.inp", "r", stdin);
    //freopen("TASK.out", "w", stdout);

    cin >> n >> m >> k;

    for(int i = 0; i < m; ++i) {
        cin >> A[i];
        A[i] -= 1;
    }

    int u = 0;
    ans = 0;
    for(int i = 0; i < m; ++i) {
        if(i == m - 1 || (A[i] - u) / k != (A[i+1] - u) / k) {
            ans++;
            u = i + 1;
        }
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
#define LL long long

using namespace std;

const int N = 101110;
LL A[N];
int ans, n, m ,k;

int main() {
    //freopen("TASK.inp", "r", stdin);
    //freopen("TASK.out", "w", stdout);

    cin >> n >> m >> k;

    for(int i = 0; i < m; ++i) {
        cin >> A[i];
        A[i] -= 1;
    }

    int u = 0;
    for(int i = 0; i < m; ++i) {
        if(i == m - 1 || (A[i] - u) / k != (A[i+1] - u) / k) {
            ans++;
            u = i + 1;
        }
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
#define LL long long

using namespace std;

const int N = 101110;
LL A[N];
LL n;
int ans, m ,k;

int main() {
    //freopen("TASK.inp", "r", stdin);
    //freopen("TASK.out", "w", stdout);

    cin >> n >> m >> k;

    for(int i = 0; i < m; ++i) {
        cin >> A[i];
        A[i] -= 1;
    }

    int u = 0;
    ans = 0;
    for(int i = 0; i < m; ++i) {
        if(i == m - 1 || (A[i] - u) / k != (A[i+1] - u) / k) {
            ans++;
            u = i + 1;
        }
    }
    cout << ans << endl;
}


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

const int N = 1e5 + 10;

long long n, a[N];
int m, ans, page = 0;
long long p1, p2, cnt, k;

int main() {
	scanf("%lld%d%lld", &n, &m, &k);
	for(int i = 1; i <= m; ++i) {
		scanf("%lld", &a[i]);
	}
	p2 = k;
	ans = a[1] <= 1LL * k;
	cnt = 0;
	for(int i = 1; i <= m; ++i) {
		//cout << "p2 = " << p2 << endl;
		if(a[i] <= p2) {
			cnt++;
			continue;
		}
		p2 += cnt;
		cnt = 0;
		if(i == m) {
			ans++;
			break;
		}
		long long nxt = a[i];
		--i;
		if(p2 >= nxt) {
			ans++;
			continue;
		}
		long long d = 1 + (nxt - p2 - 1) / k;
		p2 = p2 + 1LL * d * k;
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}


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

const int N = 1e5 + 10;

long long n;
int m, k, a[N], ans, page = 0;
long long p1, p2, cnt;

int main() {
	scanf("%lld%d%d", &n, &m, &k);
	for(int i = 1; i <= m; ++i) {
		scanf("%d", &a[i]);
	}
	p2 = k;
	ans = a[1] <= k;
	cnt = 0;
	for(int i = 1; i <= m; ++i) {
		//cout << "p2 = " << p2 << endl;
		if(a[i] <= p2) {
			cnt++;
			continue;
		}
		p2 += cnt;
		cnt = 0;
		if(i == m) {
			ans++;
			break;
		}
		int nxt = a[i];
		--i;
		if(p2 >= nxt) {
			ans++;
			continue;
		}
		long long d = 1 + (nxt - p2 - 1) / k;
		p2 = p2 + 1LL * d * k;
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}


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

const int N = 1e5 + 10;

long long n, a[N];
int m, k, ans, page = 0;
long long p1, p2, cnt;

int main() {
	scanf("%lld%d%d", &n, &m, &k);
	for(int i = 1; i <= m; ++i) {
		scanf("%lld", &a[i]);
	}
	p2 = k;
	ans = a[1] <= 1LL * k;
	cnt = 0;
	for(int i = 1; i <= m; ++i) {
		//cout << "p2 = " << p2 << endl;
		if(a[i] <= p2) {
			cnt++;
			continue;
		}
		p2 += cnt;
		cnt = 0;
		if(i == m) {
			ans++;
			break;
		}
		long long nxt = a[i];
		--i;
		if(p2 >= nxt) {
			ans++;
			continue;
		}
		long long d = 1 + (nxt - p2 - 1) / k;
		p2 = p2 + 1LL * d * k;
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}


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

const int N = 1e5 + 10;

long long n;
int m, k, a[N], ans, page = 0, p1, p2, cnt;

int main() {
	scanf("%lld%d%d", &n, &m, &k);
	for(int i = 1; i <= m; ++i) {
		scanf("%d", &a[i]);
	}
	p2 = k;
	ans = a[1] <= k;
	cnt = 0;
	for(int i = 1; i <= m; ++i) {
		//cout << "p2 = " << p2 << endl;
		if(a[i] <= p2) {
			cnt++;
			continue;
		}
		p2 += cnt;
		cnt = 0;
		if(i == m) {
			ans++;
			break;
		}
		int nxt = a[i];
		--i;
		if(p2 >= nxt) {
			ans++;
			continue;
		}
		int d = 1 + (nxt - p2 - 1) / k;
		p2 = p2 + d * k;
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int inwhat(int ind, int k) {
    ind--;
    return  ind / k;
}

int main() {
    ios_base::sync_with_stdio(false);
    int n, m, k;
    cin >> n >> m >> k;
    int p[m];
    for (int i = 0; i < m; ++i) {
        cin >> p[i];
    }
    int h = 0;
    int block = inwhat(p[0],k);
    int ans = 1;
    for (int j = 1; j < m;++j) {
        int kk = 1;
        while (j<m&&inwhat(p[j] - h, k) == block) {
            kk++;
            j++;
        }
        if(j==m)break;
        h = h + kk;
        block = inwhat(p[j] - h, k);
        ans++;
    }
    cout<<ans;
}


#include <bits/stdc++.h>

using namespace std;

long long inwhat(long long ind, long long k) {
    ind--;
    return  ind / k;
}

int main() {
    ios_base::sync_with_stdio(false);
    long long n, m, k;
    cin >> n >> m >> k;
    long long p[m];
    for (int i = 0; i < m; ++i) {
        cin >> p[i];
    }
    long long h = 0;
    long long block = inwhat(p[0],k);
    long long ans = 1;
    for (int j = 1; j < m;++j) {
        long long kk = 1;
        while (j<m&&inwhat(p[j] - h, k) == block) {
            kk++;
            j++;
        }
        if(j==m)break;
        h = h + kk;
        block = inwhat(p[j] - h, k);
        ans++;
    }
    cout<<ans;
}


#include <bits/stdc++.h>

using namespace std;

int inwhat(int ind, int k) {
    ind--;
    return  ind / k;
}

int main() {
    ios_base::sync_with_stdio(false);
    int n, m, k;
    cin >> n >> m >> k;
    int p[m];
    for (int i = 0; i < m; ++i) {
        cin >> p[i];
    }
    int h = 1;
    int block = inwhat(p[0],k);
    int ans = 1;
    for (int j = 1; j < m;++j) {
        int kk = 0;
        while (j<m&&inwhat(p[j] - h, k) == block) {
            kk++;
            j++;
        }
        if(j==m)break;
        h = h + kk;
        block = inwhat(p[j] - h, k);
        ans++;
    }
    cout<<ans;
}


#include <bits/stdc++.h>

using namespace std;

int inwhat(int ind, int k) {
    ind--;
    return  ind / k;
}

int main() {
    ios_base::sync_with_stdio(false);
    int n, m, k;
    cin >> n >> m >> k;
    int p[m];
    for (int i = 0; i < m; ++i) {
        cin >> p[i];
    }
    int h = 0;
    int block = inwhat(p[0],k);
    int ans = 0;
    for (int j = 1; j < m;) {
        int kk = 0;
        ans++;
        while (inwhat(p[j] - h, k) == block) {
            kk++;
            j++;
        }
        h = h + kk;
        block = inwhat(p[j] - h, k);
    }
    cout<<ans;
}


#include <bits/stdc++.h>

using namespace std;

int inwhat(int ind, int k) {
    ind--;
    return  ind / k;
}

int main() {
    ios_base::sync_with_stdio(false);
    int n, m, k;
    cin >> n >> m >> k;
    int p[m];
    for (int i = 0; i < m; ++i) {
        cin >> p[i];
    }
    int h = 1;
    int block = inwhat(p[0],k);
    int ans = 1;
    for (int j = 1; j < m;++j) {
        int kk = 0;
        while (j<m&&inwhat(p[j] - h, k) == block) {
            kk++;
            j++;
        }
        h = h + kk;
        block = inwhat(p[j] - h, k);
        ans++;
    }
    cout<<ans;
}


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

const int MAXN = 1e5;

long long arr[MAXN + 5];
int n,m,k;

int main() {
	//~ freopen("A.in","r",stdin);
	int c,c2;
	scanf("%*lld%d%d",&m,&k);
	for (c=0;c<m;c++) {
		scanf("%lld",&arr[c]);
		arr[c]--;
	}
	int done = 0;
	int ret = 0;
	for (int i = 0; i < m; i++) {
		if (i < done) continue;
		int pageStart = (arr[i] - done) % k;
		int curDone = 0;
		for (int j = i; j < m; j++) {
			if ((arr[j] - done) % k < pageStart) break;
			curDone++;
		}
		done += curDone;
		ret ++;
	}
	printf("%d\n",ret);

	return 0;
}


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

const int MAXN = 1e5;

long long arr[MAXN + 5];
int n,m,k;

int main() {
	//~ freopen("A.in","r",stdin);
	int c,c2;
	scanf("%*lld%d%d",&m,&k);
	for (c=0;c<m;c++) {
		scanf("%lld",&arr[c]);
		arr[c]--;
	}
	int done = 0;
	int ret = 0;
	for (int i = 0; i < m; i++) {
		if (i < done) continue;
		long long pageStart = (arr[i] - done) % k;
		int curDone = 0;
		for (int j = i; j < m; j++) {
			if ((arr[j] - done) % k < pageStart) break;
			curDone++;
		}
		done += curDone;
		ret ++;
	}
	printf("%d\n",ret);

	return 0;
}


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

const int MAXN = 1e5;

long long arr[MAXN + 5];
int n,m;
long long k;

int main() {
	//~ freopen("A.in","r",stdin);
	int c,c2;
	scanf("%*lld%d%lld",&m,&k);
	for (c=0;c<m;c++) {
		scanf("%lld",&arr[c]);
		arr[c]--;
	}
	int done = 0;
	int ret = 0;
	for (int i = 0; i < m; i++) {
		if (i < done) continue;
		long long pageStart = (arr[i] - done) % k;
		int curDone = 0;
		for (int j = i; j < m; j++) {
			if ((arr[j] - done) % k < pageStart) break;
			curDone++;
		}
		done += curDone;
		ret ++;
	}
	printf("%d\n",ret);

	return 0;
}


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

const int MAXN = 1e5;

long long arr[MAXN + 5];
int n,m;
long long k;

int main() {
	//~ freopen("A.in","r",stdin);
	int c,c2;
	scanf("%*lld%d%lld",&m,&k);
	for (c=0;c<m;c++) {
		scanf("%lld",&arr[c]);
		arr[c]--;
	}
	int done = 0;
	int ret = 0;
	for (int i = 0; i < m; i++) {
		if (i < done) continue;
		long long pageStart = (arr[i] - done) / k * k;
		int curDone = 1;
		for (int j = i + 1; j < m; j++) {
			if ((arr[j] - done) - pageStart >= k) break;
			curDone++;
		}
		done += curDone;
		ret ++;
	}
	printf("%d\n",ret);

	return 0;
}


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

const int MAXN = 1e5;

long long arr[MAXN + 5];
int n,m;
long long k;

int main() {
	//~ freopen("A.in","r",stdin);
	int c,c2;
	scanf("%*lld%d%lld",&m,&k);
	for (c=0;c<m;c++) {
		scanf("%lld",&arr[c]);
		arr[c]--;
	}
	int done = 0;
	int ret = 0;
	for (int i = 0; i < m; i++) {
		if (i < done) continue;
		long long pageStart = (arr[i] - done) % k;
		int curDone = 1;
		for (int j = i + 1; j < m; j++) {
			if ((arr[j] - done) % k <= pageStart) break;
			curDone++;
		}
		done += curDone;
		ret ++;
	}
	printf("%d\n",ret);

	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1000005,M=10005;
ll n,k,m,s,ans;
ll a[N];
int main() {
	scanf("%lld%lld%lld",&n,&m,&k);
	for(int i=1;i<=m;i++){
		scanf("%lld",&a[i]);
	}
	int i=1;
	while(i<=m){
		ans++;i++;
		while(i<=m&&((a[i-1]-s+k-1)/k==(a[i]-s+k-1)/k)) i++;
		s=(ll)i-1;
	}
	printf("%lld",ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
long long n, m, k, a[MAXN];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> k;
    long long cnt = 0, pos = 0, posa = -1, posb;
    for(long long i = 0; i < m; i++) cin >> a[i];
    if(k == 1) {
        cout << m << endl;
        return 0;
    }
    for(long long i = 0; i < m; i++, cnt++) {
        if(a[i] > pos) pos += ((a[i] - 1 - pos) / k + 1) * k;
        posb = upper_bound(a, a + m, pos) - a - 1;
        pos += posb - posa;
        i = posa = posb;
    }
    cout << cnt << endl;
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdlib>
#include<ctime>
#include<bitset>
#define ll long long
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define Abs(a) ((a<0)?-(a):(a))
// using namespace std;
namespace io{
	// char buf[1<<17],*p1=buf,*p2=buf;
	// inline int getc(){
	//      return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<17,stdin),p1==p2)?EOF:*p1++;
 //    }
    #define getc() getchar()
    template<class T>
    inline void Read(T &x){
        x=0;T f=1;char c;
        for(c=getc();c<'0'||c>'9';f=((c=='-')?-1:f),c=getc());
        for(;c>='0'&&c<='9';x=x*10+(c^48),c=getc());
        x*=f;
    }
    template<class T>
    inline void write(T a){
        if(a==0){putchar('0');return;}
        if(a<0)putchar('-'),a=-a;
        char c1[120];
        int h=0;
        while(a)c1[++h]=a%10+'0',a/=10;
        for(int i=h;i>=1;i--)putchar(c1[i]);
        return;
    }
    template<class T>
    inline void write_(T a){write(a);putchar(' ');}
    template<class T>
    inline void writeln(T a){write(a);putchar('\n');}
}
using namespace io;
template<class T>
inline T gcd(T a,T b){return a==0?b:gcd(b%a,a);}
template<class T>
inline T lcm(T a,T b){return 1ll*a/gcd(a,b)*b;}
/*----------------------------------------------------------------------*/
const int N = 1e5 + 9;
ll n, k, w[N];
int m,ans;

int main(){
    Read(n);Read(m);Read(k);
    rep(i,1,m) Read(w[i]);
    int pos = 1;
    while(pos <= m){
        ll r = ((w[pos] - pos) / k + 1) * k + pos - 1;
        while (pos <= m && w[pos] <= r) ++pos;
        ++ans;
    }
    writeln(ans);
    return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
#define N 100005

ll n; ll m; ll k;  ll a[N];  ll sum;  ll ans;

int main(){
    scanf("%lld %lld %lld",&n,&m,&k);
    for(int i=1;i<=m;++i) scanf("%lld",a+i);
    for(int i=1;i<=m;++i){
        ++ans; ++sum;
        ll num=a[i]-sum;
        ll pos=(num-1)%k+1;
        ll rnum=k-pos;
        ll rval=a[i]+rnum;
        while(i+1<=m&&a[i+1]<=rval){
            ++i; ++sum;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
//#define ll long long
using namespace std;
typedef long long ll;
int main()
{
	ll n,m,k;
	cin>>n>>m>>k;
	ll a[100005];
	for(int i=1;i<=m;i++)
	{
		cin>>a[i];
		a[i]--;		//都减去1，方便模拟
	}
	ll  ans=0,pos=1,del,res;
	while(pos<=m)
    {
        del=pos-1;	//已删除的元素个数
        res=(a[pos]-del)/k;	//第一个数所在块
        for(;((a[pos]-del)/k)==res;pos++);	//找出所有和res同块的数，pos指向第一个不同块的数

		ans++;
    }
	cout<<ans<<endl;
	return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	long long n,m,k;
	cin>>n>>m>>k;
	vector<int> v;
	for(int i=0;i<m;i++)
	{
		int a;
		cin>>a;
		v.push_back(--a);
	}
	int ans=0;
	while(!v.empty())
	{
		int res=v[0]/k+1;
		int del=1;
		for(int i=1;i<v.size();i++)
		{
			if(v[i]/k+1==res) del++;
			else break;
		}
		v.erase(v.begin(),v.begin()+del);
		for(int i=0;i<v.size();i++)
			v[i]-=del;
		ans++;
	}
	cout<<ans;
	return 0;
}


#include<cstdio>
#define int long long
const int MAXN=100050;
int n,m,k,p[MAXN];
signed main() {
	scanf("%I64d%I64d%I64d",&n,&m,&k);
	for(int i=1;i<=m;i++) scanf("%I64d",&p[i]);
	int sum=n/k,num=(p[1]-1)/k+1,cnt=0,ans=0,pcnt=0;
	for(int i=1;i<=m;i++) {
		int nownum=(p[i]-pcnt-1)/k+1;
		if(nownum==num) cnt++;
		if(nownum!=num) {
			ans++; pcnt+=cnt;
			cnt=1;
			num=(p[i]-pcnt-1)/k+1;
		}
	}
	printf("%I64d\n",ans+1);
}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;

template <typename _Tp> inline void read(_Tp &num);
template <typename _Tp> inline _Tp ab(const _Tp &x);
template <typename _Tp> inline _Tp mx(const _Tp &x, const _Tp &y);
template <typename _Tp> inline _Tp mn(const _Tp &x, const _Tp &y);
template <typename _Tp> inline void swa(_Tp &x, _Tp &y);

const int N = 100010;
typedef long long ll;

ll a[N];

int main(){
	ll n, k, ans = 0, tot = 0, now, tag = 0;
	int m;
	read(n), read(m), read(k);
	for (register int i = 1; i <= m; ++i)
		read(a[i]);
	now = ((a[1]  - 1) / k + 1) * k;
	for (register int i = 1; i <= m; ++i){
		if (a[i] - tag> now){
			++ans;
			now = ((a[i] - tot - 1) / k + 1) * k;
			tag = tot;
		}
		++tot;
	}
	cout << ans + 1 << endl;
    return 0;
}

template <typename _Tp> inline void read(_Tp &num){
    num = 0;
    char c = getchar();
    _Tp sign = 1;
    while(c < '0'||c > '9'){
        if(c == '-') sign = -1;
        c = getchar();
    }
    while(c >= '0'&&c <= '9'){
        num = (num << 1) + (num << 3) + (c ^ 48);
        c = getchar();
    }
    num *= sign;
}
template <typename _Tp> inline _Tp ab(const _Tp &x){
    return x < 0 ? -x : x;
}
template <typename _Tp> inline _Tp mx(const _Tp &x, const _Tp &y){
    return x > y ? x : y;
}
template <typename _Tp> inline _Tp mn(const _Tp &x, const _Tp &y){
    return x < y ? x : y;
}
template <typename _Tp> inline void swa(_Tp &x, _Tp &y){
	x ^= y ^= x ^= y;
}


#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
//#define rf(x) (x)=0;while(*p<48)im=*p++=='-';while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);if(im)(x)=-(x);
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
#define INFST (0x7f7f7f7f)
#define INFLLST (0x7f7f7f7f7f7f7f7fll)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
typedef complex<ld> base;
const ld EPS = (ld)1e-7;
const ld PI = acos(0) * 2;
bool isZero(const ld& x) { return abs(x) <= EPS; }
int sign(const ld& x) { return isZero(x) ? 0 : (0 < x ? 1 : -1); }
ll gcd(ll a, ll b) { for(;b;a%=b,swap(a,b)){} return abs(a); }
pll operator + (const pll& a, const pll& b) { return pll(a.first+b.first, a.second+b.second); }
pll operator - (const pll& a, const pll& b) { return pll(a.first-b.first, a.second-b.second); }
pll operator * (const pll& a, const ll& b) { return pll(a.first*b, a.second*b); }
ll operator * (const pll& a, const pll& b) { return a.first*b.second - b.first*a.second; }
ll ccw(const pll& a, const pll& b, const pll& c) { return a*b + b*c + c*a; }
void fg(vector<int> G[], int a, int b) { G[a].pb(b); G[b].pb(a); }
void fg(vector<pii> G[], int a, int b, int c) { G[a].pb({b, c}); G[b].pb({a, c}); }

const int MAXN = 100055;

ll A[MAXN];

ll M, K;
int N, Ans;

int main() {
	ios::sync_with_stdio(false);

	cin >> M >> N >> K;
	for(int i = 1; i <= N; i++) {
		cin >> A[i];
		A[i]--;
	}

	for(int s = 1, e; s <= N;) {
		e = s;
		// s-1
		ll xs = A[s]-s+1;
		xs = xs/K*K;
		ll xe = xs+K-1;
		xe += s-1;
		for(e = s+1; e <= N && A[e] <= xe; e++);
		Ans++;
		s = e;
	}

	cout << Ans << endl;
	return 0;
}


#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
//#define rf(x) (x)=0;while(*p<48)im=*p++=='-';while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);if(im)(x)=-(x);
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
#define INFST (0x7f7f7f7f)
#define INFLLST (0x7f7f7f7f7f7f7f7fll)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
typedef complex<ld> base;
const ld EPS = (ld)1e-7;
const ld PI = acos(0) * 2;
bool isZero(const ld& x) { return abs(x) <= EPS; }
int sign(const ld& x) { return isZero(x) ? 0 : (0 < x ? 1 : -1); }
ll gcd(ll a, ll b) { for(;b;a%=b,swap(a,b)){} return abs(a); }
pll operator + (const pll& a, const pll& b) { return pll(a.first+b.first, a.second+b.second); }
pll operator - (const pll& a, const pll& b) { return pll(a.first-b.first, a.second-b.second); }
pll operator * (const pll& a, const ll& b) { return pll(a.first*b, a.second*b); }
ll operator * (const pll& a, const pll& b) { return a.first*b.second - b.first*a.second; }
ll ccw(const pll& a, const pll& b, const pll& c) { return a*b + b*c + c*a; }
void fg(vector<int> G[], int a, int b) { G[a].pb(b); G[b].pb(a); }
void fg(vector<pii> G[], int a, int b, int c) { G[a].pb({b, c}); G[b].pb({a, c}); }

const int MAXN = 100055;

ll A[MAXN];

ll M;
int N, K, Ans;

int main() {
	ios::sync_with_stdio(false);

	cin >> M >> N >> K;
	for(int i = 1; i <= N; i++) {
		cin >> A[i];
		A[i]--;
	}

	for(int s = 1, e; s <= N;) {
		e = s;
		// s-1
		ll xs = A[s]-s+1;
		xs = xs/K*K;
		ll xe = xs+K-1;
		xe += s-1;
		for(e = s+1; e <= N && A[e] <= xe; e++);
		Ans++;
		s = e;
	}

	cout << Ans << endl;
	return 0;
}


#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
//#define rf(x) (x)=0;while(*p<48)im=*p++=='-';while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);if(im)(x)=-(x);
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
#define INFST (0x7f7f7f7f)
#define INFLLST (0x7f7f7f7f7f7f7f7fll)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
typedef complex<ld> base;
const ld EPS = (ld)1e-7;
const ld PI = acos(0) * 2;
bool isZero(const ld& x) { return abs(x) <= EPS; }
int sign(const ld& x) { return isZero(x) ? 0 : (0 < x ? 1 : -1); }
ll gcd(ll a, ll b) { for(;b;a%=b,swap(a,b)){} return abs(a); }
pll operator + (const pll& a, const pll& b) { return pll(a.first+b.first, a.second+b.second); }
pll operator - (const pll& a, const pll& b) { return pll(a.first-b.first, a.second-b.second); }
pll operator * (const pll& a, const ll& b) { return pll(a.first*b, a.second*b); }
ll operator * (const pll& a, const pll& b) { return a.first*b.second - b.first*a.second; }
ll ccw(const pll& a, const pll& b, const pll& c) { return a*b + b*c + c*a; }
void fg(vector<int> G[], int a, int b) { G[a].pb(b); G[b].pb(a); }
void fg(vector<pii> G[], int a, int b, int c) { G[a].pb({b, c}); G[b].pb({a, c}); }

const int MAXN = 100055;

ll A[MAXN];

ll M;
int N, K, Ans;

int main() {
	ios::sync_with_stdio(false);

	cin >> M >> N >> K;
	for(int i = 1; i <= N; i++) {
		cin >> A[i];
		A[i]--;
	}

	for(int s = 1, e; s <= N;) {
		e = s;
		// s-1
		ll xs = A[s]-s+1;
		xs = xs/K*K;
		ll xe = xs+K-1;
		for(e = s+1; e <= N && A[e] <= xe; e++);
		Ans++;
		s = e;
	}

	cout << Ans << endl;
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <memory.h>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <math.h>
#include <functional>
#include <limits.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;

const int maxn = 100000 + 10;
int nums[maxn];
LL N, M, K;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	cin >> N >> M >> K;
	for (int i = 0; i < M; i++) {
		cin >> nums[i];
		nums[i]--;
	}

	int sum = 0, ind = 0, res = 0;
	while (ind < M) {
		int t = 0, kase = (nums[ind] - sum) / K;
		while ((nums[ind] - sum) / K == kase) {
			ind++;
			t++;
		}

		res++;
		sum += t;
	}
	cout << res << endl;
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <memory.h>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <math.h>
#include <functional>
#include <limits.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;

const int maxn = 100000 + 10;
LL nums[maxn];
LL N, M, K;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	cin >> N >> M >> K;
	for (int i = 0; i < M; i++) {
		cin >> nums[i];
		nums[i]--;
	}

	LL sum = 0, ind = 0, res = 0;
	while (ind < M) {
		LL t = 0, kase = (nums[ind] - sum) / K;
		while ((nums[ind] - sum) / K == kase) {
			ind++;
			t++;
		}

		res++;
		sum += t;
	}
	cout << res << endl;
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <memory.h>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <math.h>
#include <functional>
#include <limits.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;

const int maxn = 100000 + 10;
int nums[maxn];
LL N, M, K;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	cin >> N >> M >> K;
	for (int i = 0; i < M; i++) {
		cin >> nums[i];
		nums[i]--;
	}

	int sum = 0, ind = 0, res = 0;
	while (ind < M) {
		int t = 0, kase = (nums[ind] + sum) / K;
		while ((nums[ind] + sum) / K == kase) {
			ind++;
			t++;
		}

		res++;
		sum += t;
	}
	cout << res << endl;
	return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repab(i,a,b) for(int i=a;i<=b;i++)
#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define pop pop_back
#define p0(x) cout<<x<<" "
#define p1(x) cout<<x<<'\n'
#define p2(x,y) cout<<x<<" "<<y<<'\n';
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define get(n) ll n;cin>>n
#define getarr(arr,n) ll arr[n];for(int i=0;i<n;i++) cin>>arr[i];
#define getstr(s) string s;cin>>s
#define countBits(x) __builtin_popcount (x)
using namespace std;

int main(){
  fio;
  get(n);get(m);get(k);
  getarr(arr,m);
  ll ans=0;ll element=0;
  ll i=0;
  ll page=1;
  while(i<m){
      page=((arr[i]-element-1)/k+1)*k+element;
      while(arr[i]<=page&&i<m){
        element++;
        i++;
      }
      ans++;
    }
  p1(ans);
  return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repab(i,a,b) for(int i=a;i<=b;i++)
#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define pop pop_back
#define p0(x) cout<<x<<" "
#define p1(x) cout<<x<<'\n'
#define p2(x,y) cout<<x<<" "<<y<<'\n';
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define get(n) ll n;cin>>n
#define getarr(arr,n) ll arr[n];for(int i=0;i<n;i++) cin>>arr[i];
#define getstr(s) string s;cin>>s
#define countBits(x) __builtin_popcount (x)
using namespace std;

int main(){
  fio;
  get(n);get(m);get(k);
  getarr(arr,m);
  ll ans=0;
  ll page=n/k;ll i=1;ll z=0;
  while(i<=page){
    ll element=0;
    repab(j,z,m){
      if(arr[j]<=i*k&&arr[j]>0)
        element++;
      else if(arr[j]>i*k)
        arr[j]-=element;
    }
    if(element==0)
      i++;
    else
      ans++;
    z+=element;
  }
  p1(ans);
  return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repab(i,a,b) for(int i=a;i<=b;i++)
#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define pop pop_back
#define p0(x) cout<<x<<" "
#define p1(x) cout<<x<<'\n'
#define p2(x,y) cout<<x<<" "<<y<<'\n';
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define get(n) ll n;cin>>n
#define getarr(arr,n) ll arr[n];for(int i=0;i<n;i++) cin>>arr[i];
#define getstr(s) string s;cin>>s
#define countBits(x) __builtin_popcount (x)
using namespace std;

int main(){
  fio;
  get(n);get(m);get(k);
  getarr(arr,m);
  ll ans=0;
  ll page=n/k;ll i=1;
  while(i<=page){
    ll element=0;
    rep(j,m){
      if(arr[j]<=i*k&&arr[j]>0)
        element++,arr[j]=-1;
      else if(arr[j]>i*k)
        arr[j]-=element;
    }
    if(element==0)
      i++;
    else
      ans++;
  }
  p1(ans);
  return 0;
}


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

long long n;
int m,k;
long long p[M];
int ans = 0;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m>>k;
    for(int i = 1 ; i <= m; i++){
        cin>>p[i];
        p[i]--;
    }
    int nDel = 0;
    while(nDel < m){
        long long firstPage = (p[nDel + 1] - nDel)/k;
        int cur = nDel;
        while(cur < m && (p[cur + 1] - nDel) < (firstPage + 1)*k) cur++;
        ans++;
        nDel = cur;
    }
    cout<<ans;
}


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

long long n;
int m,k;
long long p[M];
int ans = 0;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m>>k;
    for(int i = 1 ; i <= m; i++){
        cin>>p[i];
        p[i]--;
    }
    int nDel = 0;
    while(nDel < n){
        long long firstPage = (p[nDel + 1] - nDel)/k;
        int cur = nDel;
        while(cur < n && (p[cur + 1] - nDel) < (firstPage + 1)*k) cur++;
        ans++;
        nDel = cur;
    }
    cout<<ans;
}


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

long long n,k;
int m;
long long p[M];
int ans = 0;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m>>k;
    for(int i = 1 ; i <= m; i++){
        cin>>p[i];
        p[i]--;
    }
    int nDel = 0;
    while(nDel < m){
        long long firstPage = (p[nDel + 1] - nDel)/k;
        int cur = nDel;
        while(cur < m && (p[cur + 1] - nDel) < (firstPage + 1)*k) cur++;
        ans++;
        nDel = cur;
    }
    cout<<ans;
}


#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll n,m,k,ans,cnt,pos;
vector<ll> a;
vector<ll>::iterator it;
bool cmp(const ll &a,const ll &b)
{
    return a>b;
}
int main()
{
    //ios::sync_with_stdio(false);
    cin>>n>>m>>k;
    rep(i,1,m)
    {
        ll t;
        cin>>t;
        a.push_back(t);
    }
    sort(a.begin(),a.end());
    it=a.begin();
    cnt=k;
    while(1)
    {
        while(*it>cnt)
        {
            cnt+=k;
        }
        pos=lower_bound(a.begin(),a.end(),cnt)-a.begin()+1;
        if(*(it+pos-1)>cnt)
        {
            pos--;
        }
        if(pos-1==a.size())
        {
            ans++;
            break;
        }
        //cout<<cnt<<' '<<pos<<endl;
        rep(i,1,pos)
        {
            a.erase(it);
        }
        cnt+=pos;
        ans++;
        if(a.empty())
        {
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

/*

*/


#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll n,m,k,ans,cnt,pos;
vector<ll> a;
vector<ll>::iterator it;
bool cmp(const ll &a,const ll &b)
{
    return a>b;
}
int main()
{
    //ios::sync_with_stdio(false);
    cin>>n>>m>>k;
    rep(i,1,m)
    {
        ll t;
        cin>>t;
        a.push_back(t);
    }
    sort(a.begin(),a.end());
    it=a.begin();
    cnt=k;
    while(1)
    {
        while(*it>cnt)
        {
            cnt+=k;
        }
        pos=lower_bound(a.begin(),a.end(),cnt)-a.begin()+1;
        if(pos-1==a.size())
        {
            ans++;
            break;
        }
        //cout<<cnt<<' '<<pos<<endl;
        rep(i,1,pos)
        {
            a.erase(it);
        }
        cnt+=pos;
        ans++;
        if(a.empty())
        {
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

/*

*/


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+5;
long long a[maxn];
long long n,k,m;
int main()
{
    cin >> n >> m >> k;
    long long ans = 0;
    long long s = 0;//延迟量
    long long kk = k;// 基础 k 值
    long long sum = 0;//延迟总量
    for(int i = 0;i < m;i++)
    {
        cin >> a[i];
    }
    for(int i = 0;i < m;i++)
    {
        if(a[i] <= k + sum) s++;//如果这一页有特殊项目 则标记量增加
        else
        {
            if(s > 0)//如果标记量增加过
            {
                sum += s;
                i--;//回溯
                ans ++,s = 0;
                //cout << ans << " " << sum << " " << k << endl;
            }
            else if((a[i]-k - sum)/kk > 10) k = (a[i]-kk)/kk*kk,i--;//防止 TLE ，但相差页数过大 则直接跳到那页。
            else k+=kk,i--;//一页一页翻
        }
    }
    if(s > 0) ans++;
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll n,m,k,ans,cnt,pos;
vector<ll> a;
vector<ll>::iterator it;
bool cmp(const ll &a,const ll &b)
{
    return a>b;
}
int main()
{
    //ios::sync_with_stdio(false);
    cin>>n>>m>>k;
    rep(i,1,m)
    {
        ll t;
        cin>>t;
        a.push_back(t);
    }
    sort(a.begin(),a.end());
    it=a.begin();
    cnt=k;
    while(1)
    {
        while(*it>cnt)
        {
            cnt+=k;
        }
        pos=lower_bound(a.begin(),a.end(),cnt)-a.begin()+1;
        if(*(it+pos-1)>cnt)
        {
            pos--;
        }
        if(pos-1==a.size())
        {
            ans++;
            break;
        }
        cout<<cnt<<' '<<pos<<endl;
        rep(i,1,pos)
        {
            a.erase(it);
        }
        cnt+=pos;
        ans++;
        if(a.empty())
        {
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

/*

*/


#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll n,m,k,ans,cnt,pos;
vector<ll> a;
vector<ll>::iterator it;
bool cmp(const ll &a,const ll &b)
{
    return a>b;
}
int main()
{
    //ios::sync_with_stdio(false);
    cin>>n>>m>>k;
    rep(i,1,m)
    {
        ll t;
        cin>>t;
        a.push_back(t);
    }
    sort(a.begin(),a.end());
    it=a.begin();
    cnt=k;
    while(1)
    {
        while(*it>cnt)
        {
            if((*it-cnt)%k==0)
            {
                cnt=*it;
            }
            else
            {
                cnt+=(((*it-cnt)/k+1)*k);
            }
        }
        pos=lower_bound(a.begin(),a.end(),cnt)-a.begin()+1;
        if(*(it+pos-1)>cnt)
        {
            pos--;
        }
        if(pos-1==a.size())
        {
            ans++;
            break;
        }
        //cout<<cnt<<' '<<pos<<endl;
        rep(i,1,pos)
        {
            a.erase(it);
        }
        cnt+=pos;
        ans++;
        if(a.empty())
        {
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

/*

*/


#include <iostream>
#include <cstdio>
using namespace std;
long long n,m,k,a[100010],ans;
int main () {
	cin>>n>>m>>k;
	for(int i=0;i<m;i++){
		cin>>a[i];
	}
	for(int i=0;i<m;i++){
		int j=i;
		while((a[j]-i+k-1)/k==(a[i]-i+k-1)/k){
			j++;
		}
		i=j;
		ans++;
	}
	cout<<ans<<endl;
}


#include <iostream>
#include <cstdio>
using namespace std;
long long n,m,k,a[100010],ans;
int main () {
	cin>>n>>m>>k;
	for(int i=0;i<m;i++){
		cin>>a[i];
	}
	for(int i=0;i<m;){
		int j=i;
		while((a[j]-i+k-1)/k==(a[i]-i+k-1)/k){
			j++;
		}
		i=j;
		ans++;
	}
	cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=100005;
int m,cnt; ll n,k,a[MAXN];
bool judge(int x,int r)
{
    int r1=(a[x+1]-r)%k==0?(a[x+1]-r)/k-1:(a[x+1]-r)/k;
    int r2=(a[x]-r)%k==0?(a[x]-r)/k-1:(a[x]-r)/k;
    if(r1==r2) return true;
    return false;
}
int main()
{
    scanf("%lld%d%lld",&n,&m,&k);
    for(int i=1;i<=m;i++)
        scanf("%lld",&a[i]);
    int x=1,r=0;
    while(x<=m)
    {
        while(x<m&&judge(x,r)) x++;
        r=x,cnt++,x++;
    }
    printf("%d",cnt);
    return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
#define N 100005
ll n; ll m; ll k; ll a[N]; ll vis[N];
ll p; ll ans;

int main(){
	scanf("%lld %lld %lld",&m,&n,&k);
	for(ll i=1;i<=n;++i) scanf("%lld",a+i);
	p=1;
	for(ll i=1;i<=n;++i){
		if(vis[i]) continue;
		++ans;
		ll pos=(a[i]-(i-1)-1)%k+1;
		ll mx=a[i]+(k-pos);
		while(p<=n&&(a[p]<=mx)){
			vis[p]=true;
			++p;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
//#define ll long long
using namespace std;
typedef long long ll;
int main()
{
	ll n,m,k;
	cin>>n>>m>>k;
	ll a[100005];
	for(int i=1;i<=m;i++)
	{
		cin>>a[i];
		a[i]--;		//都减去1，方便模拟
	}
	ll  ans=0,pos=1,del,res;
	while(pos<=m)
    {
        del=pos-1;	//已删除的元素个数
        res=(a[pos]-del)/k;	//第一个数所在块
        for(;((a[pos]-del)/k)==res;pos++);	//找出所有和res同块的数，pos指向第一个不同块的数

		ans++;
    }
	cout<<ans<<endl;
	return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
//#define ll long long
typedef long long ll;
using namespace std;
int main()
{
	ll n,m,k;
	cin>>n>>m>>k;
	vector<ll> v;
	for(int i=0;i<m;i++)
	{
		int a;
		cin>>a;
		v.push_back(--a);
	}
	ll ans=0;
	while(!v.empty())
	{
		ll res=v[0]/k+1;
		ll del=1;
		for(int i=1;i<v.size();i++)
		{
			if(v[i]/k+1==res) del++;
			else break;
		}
		v.erase(v.begin(),v.begin()+del);
		for(int i=0;i<v.size();i++)
			v[i]-=del;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	long long n,m,k;
	cin>>n>>m>>k;
	vector<int> v;
	for(int i=0;i<m;i++)
	{
		int a;
		cin>>a;
		v.push_back(--a);
	}
	long long ans=0;
	while(!v.empty())
	{
		long long res=v[0]/k+1;
		long long del=1;
		for(int i=1;i<v.size();i++)
		{
			if(v[i]/k+1==res) del++;
			else break;
		}
		v.erase(v.begin(),v.begin()+del);
		for(int i=0;i<v.size();i++)
			v[i]-=del;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, m, k, p[100005], num = 1, tmp, i;
signed main() {
    cin >> n >> m >> k;
    for (int i = 1; i <= m; i++) cin >> p[i];
    for (; num <= m; i++) {
        int tmp = num;
        while ((k + p[tmp] - tmp) / k == (k + p[num] - tmp) / k) num++;
    }
    cout << i;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
//#define ll long long
using namespace std;
typedef long long ll;
int main()
{
	ll n,m,k;
	cin>>n>>m>>k;
	vector<ll> v;
	for(int i=0;i<m;i++)
	{
		int a;
		cin>>a;
		v.push_back(--a);
	}
	ll ans=0;
	while(!v.empty())
	{
		ll res=v[0]/k+1;
		ll del=1;
		for(int i=1;i<v.size();i++)
		{
			if(v[i]/k+1==res) del++;
			else break;
		}
		v.erase(v.begin(),v.begin()+del);
		for(int i=0;i<v.size();i++)
			v[i]-=del;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
using namespace std;
const int maxn=100050;
ll n,m,k;
ll a[maxn];
int main()
{
	cin>>n>>m>>k;
	for(int i=1;i<=m;i++) cin>>a[i],a[i]--;

	ll pos=1,del=0,temp=0;
	ll ans=0;
	while(pos<=m)
	{
		ans++;
		temp=1;
		while((pos+1<=m)&&(a[pos]-del)/k==(a[pos+1]-del)/k) pos++,temp++;
		del+=temp;
		pos++;
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100005];
int main()
{
    ll n,m,k,b,flag=0,ans=0,ant=0,c;
    cin>>n>>m>>k;
    for(int i=1; i<=m; i++)
        cin>>a[i];
    for(ll i=1,j=1; i<=n&&j<=m; i++)
    {
        if(a[j]==i&&!flag)
        {
            ans++;
            ant++;
            b=i/k;
            j++;
            flag=1;
        }
        if(a[j]==i&&flag)
        {
            c=i-ant;
            if(b!=c/k&&c%k!=0)
                ans++;
            else
                ant++;
            b=c/k;
            if(c%k==0)
                b--;
            j++;
        }

    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;

ll p[N];

int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int i,m,count;
	ll n,k,maxn,empty;
	cin>>n>>m>>k;
	for(i=0;i<m;i++) cin>>p[i];

	count=empty=i=0;
	maxn=k;//maxn=x*k+empty;
	while(i<m){
		if(p[i]<=maxn){
			while(p[i]<=maxn&&i<m){
			empty++;
			i++;
			}
			count++;
			maxn+=empty;
			empty=0;
		}
		else{
			ll temp=p[i]-maxn;//temp=x*k+c
			if(temp%k) maxn+=(temp/k+1)*k;
			else maxn+=temp;
		}
	}
	cout<<count<<endl;
	return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	long long n,m,k;
	cin>>n>>m>>k;
	vector<int> v;
	for(int i=0;i<m;i++)
	{
		int a;
		cin>>a;
		v.push_back(--a);
	}
	int ans=0;
	while(!v.empty())
	{
		int res=v[0]/k+1;
		int del=1;
		for(int i=1;i<v.size();i++)
		{
			if(v[i]/k+1==res) del++;
			else break;
		}
		v.erase(v.begin(),v.begin()+del);
		for(int i=0;i<v.size();i++)
			v[i]-=del;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<queue>
#include<map>
using namespace std;
#define re register int
#define int unsigned long long
inline int read(){
    int x=0,ff=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')ff=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
    return x*ff;
}
int n,m,k,a[100005];
signed main(){
    //freopen("tree.in","r",stdin);
    //freopen("tree.out","w",stdout);
    n=read();m=read();k=read();
    for(int i=1;i<=m;i++)a[i]=read();
    if(k==1){cout<<m<<endl;return 0;}
    sort(a+1,a+m+1);
    int l=0,j,s=0;
    for(int i=1;i<=m;i++){
        j=i+1;
        while((a[i]-l)/k-(!((a[i]-l)%k))==(a[j]-l)/k-(!((a[j]-l)%k))&&j<=m)j++;
        l+=(j-i);i=j-1;s++;
        if(j>m)break;
    }
    cout<<s<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Mll map<ll, ll>
#define Mii map<int, int>
#define Pll pair<ll, ll>
#define Vl vector<long long>
#define Vi vector<int>
#define rep(i, a, b) for(auto i=a; i<b; i++)
#define repb(i, a, b) for(auto i = a; i>=b; i--)
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define mp make_pair
#define len length
#define sz size
#define mnhp priority_queue<ll, vector<ll>, greater<ll> >
#define mxhp priority_queue<ll>
#define itr iterator
#define ini(a, b) memset(a, b, sizeof(a))
#define el '\n'

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    ll p[m];

    rep(i, 0, m)
    	cin >> p[i];

    ll st = 1;
    ll en = k;

    ll l = 0;
    ll r = m;

    ll ans = 0;

    while(l<r)
    {
    	ll num = upper_bound(p+l, p+r, en)-(p+l);
    	if(num == 0)
    	{

    		en = (en+ceil((double)(p[l]-en)/(double)k)*k, n);
    		//st = en+1;
    		//en = min(n, st+k-1);
    	}
    	else
    	{
    		ans++;
    		en = min(en+num, n);
    		l+=num;
    	}
    }

    cout << ans << el;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Mll map<ll, ll>
#define Mii map<int, int>
#define Pll pair<ll, ll>
#define Vl vector<long long>
#define Vi vector<int>
#define rep(i, a, b) for(auto i=a; i<b; i++)
#define repb(i, a, b) for(auto i = a; i>=b; i--)
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define mp make_pair
#define len length
#define sz size
#define mnhp priority_queue<ll, vector<ll>, greater<ll> >
#define mxhp priority_queue<ll>
#define itr iterator
#define ini(a, b) memset(a, b, sizeof(a))
#define el '\n'

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    ll p[m];

    rep(i, 0, m)
    	cin >> p[i];

    ll st = 1;
    ll en = k;

    ll l = 0;
    ll r = m;

    ll ans = 0;

    while(l<r)
    {
    	ll num = upper_bound(p+l, p+r, en)-(p+l);
    	if(num == 0)
    	{
    		st = en+1;
    		en = min(n, st+k-1);
    	}
    	else
    	{
    		ans++;
    		en = min(en+num, n);
    		l+=num;
    	}
    }

    cout << ans << el;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Mll map<ll, ll>
#define Mii map<int, int>
#define Pll pair<ll, ll>
#define Vl vector<long long>
#define Vi vector<int>
#define rep(i, a, b) for(auto i=a; i<b; i++)
#define repb(i, a, b) for(auto i = a; i>=b; i--)
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define mp make_pair
#define len length
#define sz size
#define mnhp priority_queue<ll, vector<ll>, greater<ll> >
#define mxhp priority_queue<ll>
#define itr iterator
#define ini(a, b) memset(a, b, sizeof(a))
#define el '\n'

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    ll p[m];

    rep(i, 0, m)
    	cin >> p[i];

    ll st = 1;
    ll en = k;

    ll l = 0;
    ll r = m;

    ll ans = 0;

    while(l<r)
    {
    	//cout <<el << "l = " << l << " r = " << r << el;
    	ll num = upper_bound(p+l, p+r, en)-(p+l);
    	if(num == 0)
    	{

    		ll add = ceil((double)(p[l]-en)/(double)k)*k;
    		en = min(en+add, n);
    		//cout << "0 en = " << en << el;
    		//st = en+1;
    		//en = min(n, st+k-1);
    	}
    	else
    	{
    		ans++;
    		en = min(en+num, n);

    		l+=num;
    		//cout << "en = " << en << " l = " << l << el;
    	}
    }

    cout << ans << el;

}


#include <bits/stdc++.h>
#define N 100005

using namespace std;

int a[N];

int main(){
	long long n;
	int m,k,res=0,ans=0;
	scanf("%I64d%d%d",&n,&m,&k);
	for(int i=0;i<m;++i){
		scanf("%d",&a[i]);
	}
	int x,i,j;
	for(i=0;i<m;){
		res++;
		x=(a[i]-1-ans)/k;
		for(j=i+1;j<m;++j){
			if(x==(a[j]-1-ans)/k);
			else break;
		}
		ans+=j-i;
		i=j;
	}
	printf("%d",res);
}


#include <bits/stdc++.h>
#define N 100005

using namespace std;

long long a[N];

int main(){
	long long n;
	long long m,k,res=0,ans=0;
	scanf("%I64d%I64d%I64d",&n,&m,&k);
	for(int i=0;i<m;++i){
		scanf("%I64d",&a[i]);
	}
	long long x,i,j;
	for(i=0;i<m;){
		res++;
		x=(a[i]-1-ans)/k;
		for(j=i+1;j<m;++j){
			if(x==(a[j]-1-ans)/k);
			else break;
		}
		ans+=j-i;
		i=j;
	}
	printf("%I64d",res);
}


#include <bits/stdc++.h>
#define N 100005

using namespace std;

long long a[N];

int main(){
	long long n;
	long long m,k,res=0,ans=0;
	scanf("%I64d%I64d%I64d",&n,&m,&k);
	for(int i=0;i<m;++i){
		scanf("%I64d",&a[i]);
	}
	int x,i,j;
	for(i=0;i<m;){
		res++;
		x=(a[i]-1-ans)/k;
		for(j=i+1;j<m;++j){
			if(x==(a[j]-1-ans)/k);
			else break;
		}
		ans+=j-i;
		i=j;
	}
	printf("%I64d",res);
}


#include<bits/stdc++.h>
using namespace std;
const int mod=1e6+3;
long long a[100008];
int main(){
    long long k,n;
    int m;
    cin>>n>>m>>k;
    int k1=0,k2=1;
    for(int i=1;i<=m;i++)
        scanf("%I64d",&a[i]);
    int ans=0;
    for(int i=2;i<=m;i++){
        if((a[i]-k1)/(k+1)==(a[i-1]-k1)/(k+1)){
            k2++;
        }
        else {
            k1=k1+k2;
            k2=1;
            ans++;
//            cout<<i<<' '<<k1<<endl;
        }
    }
    ans++;
    cout<<ans<<endl;
}


#include <bits/stdc++.h>
#define Fast_cin ios::sync_with_stdio(false), cin.tie(0);
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') fu = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if(x < 0) putchar('-'), x = -x;
    if(x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

template <typename T>
struct hash_map_t {
    vector <T> v, val, nxt;
    vector <int> head;
    int mod, tot, lastv;
    T lastans;
    bool have_ans;

    hash_map_t (int md = 0) {
        head.clear(); v.clear(); val.clear(); nxt.clear(); tot = 0; mod = md;
        nxt.resize(1); v.resize(1); val.resize(1); head.resize(mod);
        have_ans = 0;
    }

    void clear() { *this = hash_map_t(mod); }

    bool count(int x) {
        int u = x % mod;
        for(register int i = head[u]; i; i = nxt[i]) {
            if(v[i] == x) {
                have_ans = 1;
                lastv = x;
                lastans = val[i];
                return 1;
            }
        }
        return 0;
    }

    void ins(int x, int y) {
        int u = x % mod;
        nxt.push_back(head[u]); head[u] = ++tot;
        v.push_back(x); val.push_back(y);
    }

    int qry(int x) {
        if(have_ans && lastv == x) return lastans;
        count(x);
        return lastans;
    }
};

const int N = 1e5 + 5;

ll a[N];
ll n, k, last;
int m, ans;

int main() {
    cin >> n >> m >> k;
    for(register int i = 1; i <= m; i++) read(a[i]);
    for(register int i = 1; i <= m; i++) {
        ll nowb = (a[i] - last - 1) / k + 1;
        while(i < m && (a[i + 1] - last - 1) / k + 1 == nowb) ++i;
        ++ans; last = i + 1;
    }
    print(ans, '\n');
    return 0;
}


#include <bits/stdc++.h>
#define Fast_cin ios::sync_with_stdio(false), cin.tie(0);
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') fu = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if(x < 0) putchar('-'), x = -x;
    if(x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

template <typename T>
struct hash_map_t {
    vector <T> v, val, nxt;
    vector <int> head;
    int mod, tot, lastv;
    T lastans;
    bool have_ans;

    hash_map_t (int md = 0) {
        head.clear(); v.clear(); val.clear(); nxt.clear(); tot = 0; mod = md;
        nxt.resize(1); v.resize(1); val.resize(1); head.resize(mod);
        have_ans = 0;
    }

    void clear() { *this = hash_map_t(mod); }

    bool count(int x) {
        int u = x % mod;
        for(register int i = head[u]; i; i = nxt[i]) {
            if(v[i] == x) {
                have_ans = 1;
                lastv = x;
                lastans = val[i];
                return 1;
            }
        }
        return 0;
    }

    void ins(int x, int y) {
        int u = x % mod;
        nxt.push_back(head[u]); head[u] = ++tot;
        v.push_back(x); val.push_back(y);
    }

    int qry(int x) {
        if(have_ans && lastv == x) return lastans;
        count(x);
        return lastans;
    }
};

const int N = 1e5 + 5;

ll a[N];
ll n, k, last;
int m, ans;

int main() {
    cin >> n >> m >> k; last = k;
    for(register int i = 1; i <= m; i++) read(a[i]);
    sort(a + 1, a + m + 1);
    ans = (a[1] <= k);
    for(register int i = 1; i <= m; i++) {
        if(a[i] <= k) {
            ++last;
        } else if(a[i] <= last) {
            k = last;
            ++ans;
            ++last;
        } else {
            print(ans + 1, '\n');
            return 0;
        }
    }
    print(ans, '\n');
    return 0;
}


#include <bits/stdc++.h>
#define Fast_cin ios::sync_with_stdio(false), cin.tie(0);
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') fu = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if(x < 0) putchar('-'), x = -x;
    if(x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

template <typename T>
struct hash_map_t {
    vector <T> v, val, nxt;
    vector <int> head;
    int mod, tot, lastv;
    T lastans;
    bool have_ans;

    hash_map_t (int md = 0) {
        head.clear(); v.clear(); val.clear(); nxt.clear(); tot = 0; mod = md;
        nxt.resize(1); v.resize(1); val.resize(1); head.resize(mod);
        have_ans = 0;
    }

    void clear() { *this = hash_map_t(mod); }

    bool count(int x) {
        int u = x % mod;
        for(register int i = head[u]; i; i = nxt[i]) {
            if(v[i] == x) {
                have_ans = 1;
                lastv = x;
                lastans = val[i];
                return 1;
            }
        }
        return 0;
    }

    void ins(int x, int y) {
        int u = x % mod;
        nxt.push_back(head[u]); head[u] = ++tot;
        v.push_back(x); val.push_back(y);
    }

    int qry(int x) {
        if(have_ans && lastv == x) return lastans;
        count(x);
        return lastans;
    }
};

const int N = 1e5 + 5;

ll a[N];
ll n, k, last;
int m, ans;

int main() {
    cin >> n >> m >> k;
    for(register int i = 1; i <= m; i++) read(a[i]);
    for(register int i = 1; i <= m; i++) {
        ll nowb = (a[i] - last - 1) / k + 1;
        while(i < m && (a[i + 1] - last - 1) / k + 1 == nowb) ++i;
        ++ans; last = i;
    }
    print(ans, '\n');
    return 0;
}


#include <bits/stdc++.h>
#define Fast_cin ios::sync_with_stdio(false), cin.tie(0);
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') fu = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if(x < 0) putchar('-'), x = -x;
    if(x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

template <typename T>
struct hash_map_t {
    vector <T> v, val, nxt;
    vector <int> head;
    int mod, tot, lastv;
    T lastans;
    bool have_ans;

    hash_map_t (int md = 0) {
        head.clear(); v.clear(); val.clear(); nxt.clear(); tot = 0; mod = md;
        nxt.resize(1); v.resize(1); val.resize(1); head.resize(mod);
        have_ans = 0;
    }

    void clear() { *this = hash_map_t(mod); }

    bool count(int x) {
        int u = x % mod;
        for(register int i = head[u]; i; i = nxt[i]) {
            if(v[i] == x) {
                have_ans = 1;
                lastv = x;
                lastans = val[i];
                return 1;
            }
        }
        return 0;
    }

    void ins(int x, int y) {
        int u = x % mod;
        nxt.push_back(head[u]); head[u] = ++tot;
        v.push_back(x); val.push_back(y);
    }

    int qry(int x) {
        if(have_ans && lastv == x) return lastans;
        count(x);
        return lastans;
    }
};

const int N = 1e5 + 5;

ll a[N];
ll n, k, last;
int m, ans;

int main() {
    cin >> n >> m >> k;
    for(register int i = 1; i <= m; i++) read(a[i]);
    for(register int i = 1; i <= m; i++) {
        int nowb = (a[i] - last - 1) / k + 1;
        while(i < m && (a[i + 1] - last - 1) / k + 1 == nowb) ++i;
        ++ans; last = i + 1;
    }
    print(ans, '\n');
    return 0;
}


/*
10 4 5
3 5 7 10
 */
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
    ll n, m, k;
    ll key = 0, match = 0, cur_block = 0, last_block = 0, offset = 0, flush = 0;
    cin>>n>>m>>k;
    for (ll i=0; i<m; i++){
        cin>>key;
        cur_block = (key + offset - 1) / k;
        if (!i) last_block = cur_block;
        if (cur_block != last_block) {
            flush++;
            offset -= match;
            cur_block = (key + offset - 1) / k;
            last_block = cur_block;
            match = 1;
        } else {
            match++;
        }
    }
    if (match) flush++;
    cout<<flush<<endl;
}


/*
10 4 5
3 5 7 10
 */
#include <bits/stdc++.h>
#define ll long long
using namespace std;

unordered_set<ll> sp_set;
int main() {
    ll n, m, k;
    ll cursor = 0, match = 0, flush = 0;
    cin>>n>>m>>k;
    for (ll i=0; i<m; i++){
        ll key;
        cin>>key;
        sp_set.insert(key);
    }

    for (int i = 1; i<=n; i++){
        if (sp_set.count(i)) match++;
        cursor++;
        if (cursor == k){
            if (!match) cursor = 0;
            else {
              cursor -= match;
              flush++;
              match = 0;
            }
        }
    }
    if (match) flush++;
    cout<<flush<<endl;
}


/*
10 4 5
3 5 7 10
 */
#include <bits/stdc++.h>
#define ll long long
using namespace std;

unordered_set<ll> sp_set;
int main() {
    ll n, m, k;
    ll cursor = 0, match = 0, flush = 0;
    cin>>n>>m>>k;
    for (ll i=0; i<m; i++){
        ll key;
        cin>>key;
        sp_set.insert(key);
    }

    for (int i = 1; i<=n; i++){
        if (sp_set.count(i)) match++;
        cursor++;
        if (cursor == k){
            if (!match) cursor = 0;
            else {
              cursor -= match;
              flush++;
              match = 0;
            }
        }
    }
    cout<<flush<<endl;
}


#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
template<typename S, typename T> inline bool Min(S &a, const T &b){ return a > b ? a = b, true : false; }
template<typename S, typename T> inline bool Max(S &a, const T &b){ return a < b ? a = b, true : false; }
template<typename S, typename T> inline void Adm(S &a, const T &b){ a = (a + b) % MOD; if (a < 0) a += MOD; }
template<typename S, typename T> inline void Mum(S &a, const T &b){ a = 1LL * a * b % MOD; }
inline ll Mum(initializer_list<ll> ls){ ll a = 1; for (ll b : ls)a = a * b % MOD; return a; }
//emplace pair

const int N = 1e5 + 100;
ll a[N];

int main()
{
#ifdef LOCAL
	freopen("C:/input.txt", "r", stdin);
#endif
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 1; i <= m; ++i)
		scanf("%I64d", &a[i]);
	int p = 1, ans = 0;
	ll q = k; //q当前页范围
	while (p <= m)
	{
		int cnt = 0; //删除次数
		while (p <= m && a[p] <= q)
			++p, ++cnt;
		if (cnt)
			q += cnt, ++ans; //范围后移
		else
			q += (a[p] - q + k - 1) / k * k; //上取整跳到合适页
	}
	cout << ans << endl;

	return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
template<typename S, typename T> inline bool Min(S &a, const T &b){ return a > b ? a = b, true : false; }
template<typename S, typename T> inline bool Max(S &a, const T &b){ return a < b ? a = b, true : false; }
template<typename S, typename T> inline void Adm(S &a, const T &b){ a = (a + b) % MOD; if (a < 0) a += MOD; }
template<typename S, typename T> inline void Mum(S &a, const T &b){ a = 1LL * a * b % MOD; }
inline ll Mum(initializer_list<ll> ls){ ll a = 1; for (ll b : ls)a = a * b % MOD; return a; }
//emplace pair

int main()
{
#ifdef LOCAL
	freopen("C:/input.txt", "r", stdin);
#endif
	ll n, m, k;
	cin >> n >> m >> k;
	set<ll> st;
	for (int i = 1; i <= m; ++i)
	{
		ll x;
		scanf("%lld", &x);
		st.insert(x);
	}
	int ans = 0;
	ll pos = k; //当前页范围
	while (!st.empty())
	{
		if (*st.begin() <= pos)
		{
			++ans;
			int cnt = 0;
			while (!st.empty() && *st.begin() <= pos)
				st.erase(st.begin()), ++cnt;
			pos += cnt;
		}
		else
		{
			ll len = *st.begin() - pos;
			pos += (len + k - 1) / k * k;
		}
	}
	cout << ans << endl;

	return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
template<typename S, typename T> inline bool Min(S &a, const T &b){ return a > b ? a = b, true : false; }
template<typename S, typename T> inline bool Max(S &a, const T &b){ return a < b ? a = b, true : false; }
template<typename S, typename T> inline void Adm(S &a, const T &b){ a = (a + b) % MOD; if (a < 0) a += MOD; }
template<typename S, typename T> inline void Mum(S &a, const T &b){ a = 1LL * a * b % MOD; }
inline ll Mum(initializer_list<ll> ls){ ll a = 1; for (ll b : ls)a = a * b % MOD; return a; }
//emplace pair

const int N = 1e5 + 100;
ll a[N];

int main()
{
#ifdef LOCAL
	freopen("C:/input.txt", "r", stdin);
#endif
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 1; i <= m; ++i)
		scanf("%lld", &a[i]);
	int p = 1, ans = 0;
	ll q = k; //q当前页范围
	while (p <= m)
	{
		int cnt = 0; //删除次数
		while (p <= m && a[p] <= q)
			++p, ++cnt;
		if (cnt)
			q += cnt, ++ans; //范围后移
		else
			q += (a[p] - q + k - 1) / k * k; //上取整跳到合适页
	}
	cout << ans << endl;

	return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
template<typename S, typename T> inline bool Min(S &a, const T &b){ return a > b ? a = b, true : false; }
template<typename S, typename T> inline bool Max(S &a, const T &b){ return a < b ? a = b, true : false; }
template<typename S, typename T> inline void Adm(S &a, const T &b){ a = (a + b) % MOD; if (a < 0) a += MOD; }
template<typename S, typename T> inline void Mum(S &a, const T &b){ a = 1LL * a * b % MOD; }
inline ll Mum(initializer_list<ll> ls){ ll a = 1; for (ll b : ls)a = a * b % MOD; return a; }
//emplace pair

const int N = 1e5 + 100;
ll a[N];

int main()
{
#ifdef LOCAL
	freopen("C:/input.txt", "r", stdin);
#endif
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 1; i <= m; ++i)
		scanf("%lld", &a[i]);
	int p = 1, q = k, ans = 0; //q当前页范围
	while (p <= m)
	{
		int cnt = 0; //删除次数
		while (p <= m && a[p] <= q)
			++p, ++cnt;
		if (cnt)
			q += cnt, ++ans; //范围后移
		else
			q += (a[p] - q + k - 1) / k * k; //上取整跳到合适页
	}
	cout << ans << endl;

	return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
template<typename S, typename T> inline bool Min(S &a, const T &b){ return a > b ? a = b, true : false; }
template<typename S, typename T> inline bool Max(S &a, const T &b){ return a < b ? a = b, true : false; }
template<typename S, typename T> inline void Adm(S &a, const T &b){ a = (a + b) % MOD; if (a < 0) a += MOD; }
template<typename S, typename T> inline void Mum(S &a, const T &b){ a = 1LL * a * b % MOD; }
inline ll Mum(initializer_list<ll> ls){ ll a = 1; for (ll b : ls)a = a * b % MOD; return a; }
//emplace pair

const int N = 1e5 + 100;
ll a[N];

int main()
{
#ifdef LOCAL
	freopen("C:/input.txt", "r", stdin);
#endif
	ll n, m, k;
	cin >> n >> m >> k;
	for (int i = 1; i <= m; ++i)
		scanf("%lld", &a[i]);
	int p = 1, ans = 0;
	ll q = k; //q当前页范围
	while (p <= m)
	{
		int cnt = 0; //删除次数
		while (p <= m && a[p] <= q)
			++p, ++cnt;
		if (cnt)
			q += cnt, ++ans; //范围后移
		else
			q += (a[p] - q + k - 1) / k * k; //上取整跳到合适页
	}
	cout << ans << endl;

	return 0;
}


#include<bits/stdc++.h>

#define ll long long
#define INF 2147483647

int inp(){
    char c = getchar();
    while(c < '0' || c > '9')
        c = getchar();
    int sum = 0;
    while(c >= '0' && c <= '9'){
        sum = sum * 10 + c - '0';
        c = getchar();
    }
    return sum;
}

int pos[100010];

int main(){
    int n = inp();
    int m = inp();
    int k = inp();
    int ans = 1;
    int delta = 0;
    for(int i = 1; i <= m; i++)
        pos[i] = inp();
    int lim = ((pos[1] - 1) / k + 1) * k;
    int p = 0;
    while(true){
        p = std::upper_bound(pos + 1, pos + m + 1, lim + p) - pos - 1;
        if(p == m)
            break;
        ans++;
        lim = (((pos[p + 1] - p) - 1) / k + 1) * k;
    }
    printf("%d\n", ans);
}


#include<bits/stdc++.h>

#define ll long long
#define INF 2147483647
#define int long long

int inp(){
    char c = getchar();
    while(c < '0' || c > '9')
        c = getchar();
    int sum = 0;
    while(c >= '0' && c <= '9'){
        sum = sum * 10 + c - '0';
        c = getchar();
    }
    return sum;
}

int pos[100010];

signed main(){
    ll n = inp();
    int m = inp();
    int k = inp();
    int ans = 1;
    int delta = 0;
    for(int i = 1; i <= m; i++)
        pos[i] = inp();
    int lim = ((pos[1] - 1) / k + 1) * k;
    int p = 0;
    while(true){
        p = std::upper_bound(pos + 1, pos + m + 1, lim + p) - pos - 1;
        if(p == m)
            break;
        ans++;
        lim = (((pos[p + 1] - p) - 1) / k + 1) * k;
    }
    printf("%lld\n", ans);
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,m,k,c=0,d=0,s=0;
    cin>>n>>m>>k;

    ll a[m];

    for(i=0;i<m;i++)
        cin>>a[i];
    for(i=0;i<m;i++)
    {
        if(a[i]<=k)
            s++;
        else
            break;
    }
    if(i>0)
    c=c+1;
    else
        k=k+k;
    for(;i<m&&k<=n;)
    {
        if(a[i]<=k+s)
            {i++;s++;}
        else
        {
            c=c+1;
            s=0;
            k=k+k;
        }
    }
    if(i>=m&&a[i-1]<=k+s)
        c++;
    cout<<c<<endl;
}


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef unsigned long long ull ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

ll arrPow[100005], arrHash1[100005], arrHash2[100005] ;
ll p1 = 31, mod1 = 1001110699, maxPow = 100000 ;

void init()
{
    arrPow[0] = 1 ;
    for (int i = 1; i <= maxPow; i++) {
        arrPow[i] = (arrPow[i - 1] * p1) % mod1 ;
    }
    return ;
}
void makeHash(string s1, string s2)
{
    arrHash1[0] = arrHash2[0] = 0 ;
    for (int i = 0; i < s1.size(); i++) {
        arrHash1[i + 1] = (arrHash1[i] + ((s1[i] - 'a' + 1) * arrPow[i])) % mod1 ;
    }
    for (int i = 0; i < s2.size(); i++) {
        arrHash2[i + 1] = (arrHash2[i] + ((s2[i] - 'a' + 1) * arrPow[i])) % mod1 ;
    }
    return ;
}
ll getHash1(ll L, ll R)
{
    ll ans = (arrHash1[R] - arrHash1[L - 1] + mod1) % mod1 ;
    ans *= arrPow[maxPow - (R - 1)] ;
    ans %= mod1 ;
    return ans ;
}
ll getHash2(ll L, ll R)
{
    ll ans = (arrHash2[R] - arrHash2[L - 1] + mod1) % mod1 ;
    ans *= arrPow[maxPow - (R - 1)] ;
    ans %= mod1 ;
    return ans ;
}
ll preFixsufFix (string s1, string s2)
{
    makeHash(s1, s2) ;
    ll sz1 = s1.size(), sz2 = s2.size(), len ;
    for (int i = 1; i <= sz1; i++) {
        len = sz1 - i + 1 ;
        if (len <= sz2) {
            if (getHash1(i, sz1) == getHash2(1, len))   return len ;
        }
    }
    return 0 ;
}

int main()
{
    fastIO ;
    init() ;
    string s1, s2, s3 ;
    cin >> s1 >> s2 >> s3 ;
    ll ans = INF, cnt = 0, sz = s1.size() + s2.size() + s3.size(), AB, BC, AC, BA, CB, CA ;

    AB = preFixsufFix(s1, s2), BA = preFixsufFix(s2, s1) ;
    BC = preFixsufFix(s2, s3), CB = preFixsufFix(s3, s2) ;
    AC = preFixsufFix(s1, s3), CA = preFixsufFix(s3, s1) ;

    ans = min(ans, sz - AB - BC) ;
    ans = min(ans, sz - BA - AC) ;

    ans = min(ans, sz - AC - CB) ;
    ans = min(ans, sz - BC - CA) ;

    ans = min(ans, sz - CA - AB) ;
    ans = min(ans, sz - CB - BA) ;

    cout << ans << "\n" ;

    return 0 ;
}


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef unsigned long long ull ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

ll arrPow[100005], arrHash1[100005], arrHash2[100005], mat[5][5] ;
ll p1 = 31, mod1 = 1001110699, maxPow = 100000 ;

void init()
{
    arrPow[0] = 1 ;
    for (int i = 1; i <= maxPow; i++) {
        arrPow[i] = (arrPow[i - 1] * p1) % mod1 ;
    }
    for (int i = 1; i <= 3; i++) {
        for (int j = 1; j <= 3; j++) {
            mat[i][j] = -1 ;
        }
    }
    return ;
}
void makeHash(string s1, string s2)
{
    arrHash1[0] = arrHash2[0] = 0 ;
    for (int i = 0; i < s1.size(); i++) {
        arrHash1[i + 1] = (arrHash1[i] + ((s1[i] - 'a' + 1) * arrPow[i])) % mod1 ;
    }
    for (int i = 0; i < s2.size(); i++) {
        arrHash2[i + 1] = (arrHash2[i] + ((s2[i] - 'a' + 1) * arrPow[i])) % mod1 ;
    }
    return ;
}
ll getHash1(ll L, ll R)
{
    ll ans = (arrHash1[R] - arrHash1[L - 1] + mod1) % mod1 ;
    ans *= arrPow[maxPow - (R - 1)] ;
    ans %= mod1 ;
    return ans ;
}
ll getHash2(ll L, ll R)
{
    ll ans = (arrHash2[R] - arrHash2[L - 1] + mod1) % mod1 ;
    ans *= arrPow[maxPow - (R - 1)] ;
    ans %= mod1 ;
    return ans ;
}
ll preFixsufFix (string s1, string s2)
{
    makeHash(s1, s2) ;
    ll sz1 = s1.size(), sz2 = s2.size(), len ;
    for (int i = 1; i <= sz1; i++) {
        len = sz1 - i + 1 ;
        if (len <= sz2) {
            if (getHash1(i, sz1) == getHash2(1, len))   return len ;
        }
    }
    return 0 ;
}
bool contains(string s1, string s2)
{
    makeHash(s1, s2) ;
    if (s2.size() > s1.size())  return false ;
    ll sz = s2.size(), lim = s1.size() - sz + 1 ;
    for (int i = 1; i <= lim; i++) {
        if (getHash1(i, i + sz - 1) == getHash2(1, sz)) {
            return true ;
        }
    }
    return false ;
}

int main()
{
    fastIO ;
    init() ;
    string s1, s2, s3 ;
    cin >> s1 >> s2 >> s3 ;
    ll ans = INF, sz12 = s1.size() + s2.size(), sz13 = s1.size() + s3.size(), sz23 = s2.size() + s3.size(), sz = s1.size() + s2.size() + s3.size(), AB, BC, AC, BA, CB, CA ;

    AB = preFixsufFix(s1, s2), BA = preFixsufFix(s2, s1) ;
    BC = preFixsufFix(s2, s3), CB = preFixsufFix(s3, s2) ;
    AC = preFixsufFix(s1, s3), CA = preFixsufFix(s3, s1) ;

    mat[1][2] = contains(s1, s2), mat[2][1] = contains(s2, s1) ;
    mat[1][3] = contains(s1, s3), mat[3][1] = contains(s3, s1) ;
    mat[2][3] = contains(s2, s3), mat[3][2] = contains(s3, s2) ;

    if (mat[1][2]) {
        if (mat[1][3])   ans = min(ans, (ll)s1.size()) ;
        if (mat[3][1])  ans = min(ans, (ll)s3.size()) ;
        ans = min(ans, sz13 - AC) ;
        ans = min(ans, sz13 - CA) ;
    }
    if (mat[2][1]) {
        if (mat[2][3])   ans = min(ans, (ll)s2.size()) ;
        if (mat[3][2])  ans = min(ans, (ll)s3.size()) ;
        ans = min(ans, sz23 - BC) ;
        ans = min(ans, sz23 - CB) ;
    }
    if (mat[1][3]) {
        if (mat[1][2])   ans = min(ans, (ll)s1.size()) ;
        if (mat[2][1])   ans = min(ans, (ll)s2.size()) ;
        ans = min(ans, sz12 - AB) ;
        ans = min(ans, sz12 - BA) ;
    }
    if (mat[3][1]) {
        if (mat[3][2])   ans = min(ans, (ll)s3.size()) ;
        if (mat[2][3])   ans = min(ans, (ll)s2.size()) ;
        ans = min(ans, sz23 - BC) ;
        ans = min(ans, sz23 - CB) ;
    }
    if (mat[2][3]) {
        if (mat[2][1])   ans = min(ans, (ll)s2.size()) ;
        if (mat[1][2])   ans = min(ans, (ll)s1.size()) ;
        ans = min(ans, sz23 - BC) ;
        ans = min(ans, sz23 - CB) ;
    }
    if (mat[3][2]) {
        if (mat[3][1])   ans = min(ans, (ll)s3.size()) ;
        if (mat[1][3])   ans = min(ans, (ll)s1.size()) ;
        ans = min(ans, sz13 - AC) ;
        ans = min(ans, sz13 - CA) ;
    }
    ans = min(ans, sz - AB - BC) ;  // ABC //
    ans = min(ans, sz - AC - CB) ;  // ACB //
    ans = min(ans, sz - BA - AC) ;  // BAC //
    ans = min(ans, sz - BC - CA) ;  // BCA //
    ans = min(ans, sz - CA - AB) ;  // CAB //
    ans = min(ans, sz - CB - BA) ;  // CBA //

    cout << ans << "\n" ;

    return 0 ;
}


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef unsigned long long ull ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

ll preFixsufFix (string s1, string s2)
{
    ll ans = 0 ;
    for (int i = 0, j = s2.size() - 1; i < s1.size(), j >= 0; i++, j--) {
        if (s1[i] == s2[j]) ans++ ;
        else    break ;
    }
    return ans ;
}

int main()
{
    fastIO ;
    string s1, s2, s3 ;
    cin >> s1 >> s2 >> s3 ;
    ll ans = INF, cnt = 0, sz = s1.size() + s2.size() + s3.size(), AB, BC, AC, BA, CB, CA ;
    AB = preFixsufFix(s1, s2), BA = preFixsufFix(s2, s1) ;
    BC = preFixsufFix(s2, s3), CB = preFixsufFix(s3, s2) ;
    AC = preFixsufFix(s1, s3), CA = preFixsufFix(s3, s1) ;
    ans = min(ans, sz - AB - BC) ;
    ans = min(ans, sz - BA - AC) ;

    ans = min(ans, sz - AC - CB) ;
    ans = min(ans, sz - BC - CA) ;

    ans = min(ans, sz - CA - AB) ;
    ans = min(ans, sz - CB - BA) ;

    cout << ans << "\n" ;

    return 0 ;
}


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef unsigned long long ull ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

ll arrPow[100005], arrHash1[100005], arrHash2[100005], mat[5][5] ;
ll p1 = 31, mod1 = 1001110699, maxPow = 100000 ;

void init()
{
    arrPow[0] = 1 ;
    for (int i = 1; i <= maxPow; i++) {
        arrPow[i] = (arrPow[i - 1] * p1) % mod1 ;
    }
    return ;
}
void makeHash(string s1, string s2)
{
    arrHash1[0] = arrHash2[0] = 0 ;
    for (int i = 0; i < s1.size(); i++) {
        arrHash1[i + 1] = (arrHash1[i] + ((s1[i] - 'a' + 1) * arrPow[i])) % mod1 ;
    }
    for (int i = 0; i < s2.size(); i++) {
        arrHash2[i + 1] = (arrHash2[i] + ((s2[i] - 'a' + 1) * arrPow[i])) % mod1 ;
    }
    return ;
}
ll getHash1(ll L, ll R)
{
    ll ans = (arrHash1[R] - arrHash1[L - 1] + mod1) % mod1 ;
    ans *= arrPow[maxPow - (R - 1)] ;
    ans %= mod1 ;
    return ans ;
}
ll getHash2(ll L, ll R)
{
    ll ans = (arrHash2[R] - arrHash2[L - 1] + mod1) % mod1 ;
    ans *= arrPow[maxPow - (R - 1)] ;
    ans %= mod1 ;
    return ans ;
}
ll preFixsufFix (string s1, string s2)
{
    makeHash(s1, s2) ;
    ll sz1 = s1.size(), sz2 = s2.size(), len ;
    for (int i = 1; i <= sz1; i++) {
        len = sz1 - i + 1 ;
        if (len <= sz2) {
            if (getHash1(i, sz1) == getHash2(1, len))   return len ;
        }
    }
    return 0 ;
}
bool contains(string s1, string s2)
{
    makeHash(s1, s2) ;
    if (s2.size() > s1.size())  return false ;
    ll sz = s2.size(), lim = s1.size() - sz + 1 ;
    for (int i = 1; i <= lim; i++) {
        if (getHash1(i, i + sz - 1) == getHash2(1, sz)) {
            return true ;
        }
    }
    return false ;
}

int main()
{
    fastIO ;
    init() ;
    string s1, s2, s3 ;
    cin >> s1 >> s2 >> s3 ;
    ll ans = INF, sz12 = s1.size() + s2.size(), sz13 = s1.size() + s3.size(), sz23 = s2.size() + s3.size(), sz = s1.size() + s2.size() + s3.size(), AB, BC, AC, BA, CB, CA ;

    AB = preFixsufFix(s1, s2), BA = preFixsufFix(s2, s1) ;
    BC = preFixsufFix(s2, s3), CB = preFixsufFix(s3, s2) ;
    AC = preFixsufFix(s1, s3), CA = preFixsufFix(s3, s1) ;

    mat[1][2] = contains(s1, s2), mat[2][1] = contains(s2, s1) ;
    mat[1][3] = contains(s1, s3), mat[3][1] = contains(s3, s1) ;
    mat[2][3] = contains(s2, s3), mat[3][2] = contains(s3, s2) ;

    if (mat[1][2]) {
        if (mat[1][3])   ans = min(ans, (ll)s1.size()) ;
        if (mat[3][1])  ans = min(ans, (ll)s3.size()) ;
        ans = min(ans, sz13 - AC) ;
        ans = min(ans, sz13 - CA) ;
    }
    if (mat[2][1]) {
        if (mat[2][3])   ans = min(ans, (ll)s2.size()) ;
        if (mat[3][2])  ans = min(ans, (ll)s3.size()) ;
        ans = min(ans, sz23 - BC) ;
        ans = min(ans, sz23 - CB) ;
    }
    if (mat[1][3]) {
        if (mat[1][2])   ans = min(ans, (ll)s1.size()) ;
        if (mat[2][1])   ans = min(ans, (ll)s2.size()) ;
        ans = min(ans, sz12 - AB) ;
        ans = min(ans, sz12 - BA) ;
    }
    if (mat[3][1]) {
        if (mat[3][2])   ans = min(ans, (ll)s3.size()) ;
        if (mat[2][3])   ans = min(ans, (ll)s2.size()) ;
        ans = min(ans, sz23 - BC) ;
        ans = min(ans, sz23 - CB) ;
    }
    if (mat[2][3]) {
        if (mat[2][1])   ans = min(ans, (ll)s2.size()) ;
        if (mat[1][2])   ans = min(ans, (ll)s1.size()) ;
        ans = min(ans, sz12 - AB) ;
        ans = min(ans, sz12 - BA) ;
    }
    if (mat[3][2]) {
        if (mat[3][1])   ans = min(ans, (ll)s3.size()) ;
        if (mat[1][3])   ans = min(ans, (ll)s1.size()) ;
        ans = min(ans, sz13 - AC) ;
        ans = min(ans, sz13 - CA) ;
    }
    ans = min(ans, sz - AB - BC) ;  // ABC //
    ans = min(ans, sz - AC - CB) ;  // ACB //
    ans = min(ans, sz - BA - AC) ;  // BAC //
    ans = min(ans, sz - BC - CA) ;  // BCA //
    ans = min(ans, sz - CA - AB) ;  // CAB //
    ans = min(ans, sz - CB - BA) ;  // CBA //

    cout << ans << "\n" ;

    return 0 ;
}


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef unsigned long long ull ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

ll preFixsufFix (string s1, string s2)
{
    ll ans = 0 ;
    for (int i = 0, j = s2.size() - 1; i < s1.size(), j >= 0; i++, j--) {
        if (s1[i] == s2[j]) ans++ ;
        else    break ;
    }
    return ans ;
}

int main()
{
    fastIO ;
    string s1, s2, s3 ;
    ll ans = INF, cnt = 0, sz = s1.size() + s2.size() + s3.size(), AB, BC, AC, BA, CB, CA ;
    AB = preFixsufFix(s1, s2), BA = preFixsufFix(s2, s1) ;
    BC = preFixsufFix(s2, s3), CB = preFixsufFix(s3, s2) ;
    AC = preFixsufFix(s1, s3), CA = preFixsufFix(s3, s1) ;
    ans = min(ans, sz - AB - BC) ;
    ans = min(ans, sz - BA - AC) ;

    ans = min(ans, sz - AC - CB) ;
    ans = min(ans, sz - BC - CA) ;

    ans = min(ans, sz - CA - AB) ;
    ans = min(ans, sz - CB - BA) ;

    cout << ans << "\n" ;

    return 0 ;
}


#include <cassert>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <tuple>
#include <vector>

#define STRING_IMPL(...) #__VA_ARGS__
#define STRING(...) STRING_IMPL(__VA_ARGS__)

#ifdef DEBUG
#define debug(...) void(std::cerr << "[" __FILE__ ":" STRING(__LINE__)  "] " #__VA_ARGS__ " = " << (__VA_ARGS__) << '\n')
#else
#define debug(...) void()
#endif

template <typename... Ts>
std::ostream& operator<<(std::ostream &os, std::tuple<Ts...> const &theTuple) {
    os << '(';
    std::apply([&os](Ts const&... tupleArgs) {
            std::size_t n{0};
            ((os << tupleArgs << (++n != sizeof...(Ts) ? ", " : "")), ...);
        }, theTuple);
    return os << ')';
}

template <typename T>
std::ostream& operator<< (std::ostream &os, std::vector<T> const &v) {
	os << '[';
	std::copy(begin(v), end(v), std::ostream_iterator<T>(os, ", "));
	os << "\b\b]";
	return os;
}

constexpr size_t N = 3;

std::vector<size_t> zalgo(std::string const &S) noexcept {
	size_t l = 0, r = 0;
	std::vector<size_t> Z;
	Z.reserve(S.size());
	Z.push_back(0);

	for (size_t i = 1; i < S.size(); ++i)
		if (i > r) {
			l = r = i;
			while (r < S.size() && S[r] == S[r-l])
				++r;
			Z.push_back(r - l);
		} else if (Z[i - l] > r - i) {
			l = i;
			while (r < S.size() && S[r] == S[r-l])
				++r;
			Z.push_back(r - l);
		} else {
			Z.push_back(Z[i - l]);
		}

	assert(Z.size() == S.size());
	return Z;
}

std::string merge_cat(std::string const &lhs, std::string const &rhs) {
	std::string cat = rhs + lhs;
	auto const Z = zalgo(cat);

	size_t overlapping = 0;
	for (size_t i = cat.size() - std::min(lhs.size(), rhs.size()); i < cat.size(); ++i)
		if (i + Z[i] == cat.size()) {
			overlapping = Z[i];
			break;
		}

	cat.clear();
	std::copy(begin(lhs), end(lhs), back_inserter(cat));
	std::copy(begin(rhs) + overlapping, end(rhs), back_inserter(cat));

	return cat;
}

bool contains(std::string const &a, std::string const &b) noexcept {
	auto const Z = zalgo(b + a);

	for (size_t i = b.size(); i < Z.size(); ++i)
		if (Z[i] == b.size())
			return true;

	return false;
}

size_t solve(std::vector<std::string> &S) {
	auto min = SIZE_MAX;

	sort(begin(S), end(S), [](std::string const &a, std::string const &b) { return a.size() < b.size(); });
	for (size_t i = 0; i < S.size(); ++i)
		for (size_t j = i+1; j < S.size(); ++j)
			if (contains(S[j], S[i])) {
				S.erase(begin(S) + i);
				break;
			}

	sort(begin(S), end(S));

	do {
		std::string cat = "";
		for (size_t i = 0; i < S.size(); ++i)
			cat = merge_cat(cat, S[i]);
		min = std::min(min, cat.size());

		cat = "";
		for (size_t i = S.size() - 1; i < S.size(); --i)
			cat = merge_cat(S[i], cat);
		min = std::min(min, cat.size());
	} while (next_permutation(begin(S), end(S)));

	return min;
}

int main() {
	std::vector<std::string> S;
	for (size_t i = 0; i < N; ++i) {
		std::string x;
		std::cin >> x;
		S.emplace_back(std::move(x));
	}
	std::cout << solve(S) << '\n';
}


#include <cassert>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <tuple>
#include <vector>

#define STRING_IMPL(...) #__VA_ARGS__
#define STRING(...) STRING_IMPL(__VA_ARGS__)

#ifdef DEBUG
#define debug(...) void(std::cerr << "[" __FILE__ ":" STRING(__LINE__)  "] " #__VA_ARGS__ " = " << (__VA_ARGS__) << '\n')
#else
#define debug(...) void()
#endif

template <typename... Ts>
std::ostream& operator<<(std::ostream &os, std::tuple<Ts...> const &theTuple) {
    os << '(';
    std::apply([&os](Ts const&... tupleArgs) {
            std::size_t n{0};
            ((os << tupleArgs << (++n != sizeof...(Ts) ? ", " : "")), ...);
        }, theTuple);
    return os << ')';
}

template <typename T>
std::ostream& operator<< (std::ostream &os, std::vector<T> const &v) {
	os << '[';
	std::copy(begin(v), end(v), std::ostream_iterator<T>(os, ", "));
	os << "\b\b]";
	return os;
}

constexpr size_t N = 3;

std::vector<size_t> zalgo(std::string const &S) noexcept {
	size_t l = 0, r = 0;
	std::vector<size_t> Z;
	Z.reserve(S.size());
	Z.push_back(Z.size());

	for (size_t i = 1; i < S.size(); ++i)
		if (i > r) {
			l = r = i;
			while (r < S.size() && S[r] == S[r-l])
				++r;
			Z.push_back(r - l);
		} else if (Z[i - l] > r - i) {
			l = i;
			while (r < S.size() && S[r] == S[r-l])
				++r;
			Z.push_back(r - l);
		} else {
			Z.push_back(Z[i - l]);
		}

	assert(Z.size() == S.size());
	return Z;
}

std::string merge_cat(std::string const &lhs, std::string const &rhs) {
	std::string cat = rhs + lhs;
	auto const Z = zalgo(cat);

	size_t overlapping = 0;
	for (size_t i = cat.size() - std::min(lhs.size(), rhs.size()); i < cat.size(); ++i)
		if (i + Z[i] == cat.size()) {
			overlapping = Z[i];
			break;
		}

	cat.clear();
	std::copy(begin(lhs), end(lhs), back_inserter(cat));
	std::copy(begin(rhs) + overlapping, end(rhs), back_inserter(cat));
	return cat;
}

bool contains(std::string const &a, std::string const &b) noexcept {
	auto const Z = zalgo(b + a);

	for (size_t i = b.size(); i < Z.size(); ++i)
		if (Z[i] >= b.size())
			return true;

	return false;
}

size_t solve(std::vector<std::string> &S) {
	auto const l = [](std::string const &a, std::string const &b) { return a.size() != b.size() ? a.size() < b.size() : a < b; };

	sort(begin(S), end(S), l);
	for (size_t i = S.size() - 1; i < S.size(); --i)
		for (size_t j = i+1; j < S.size(); ++j)
			if (contains(S[j], S[i])) {
				S.erase(begin(S) + i);
				break;
			}

	auto min = SIZE_MAX;

	do {
		std::string cat = "";
		for (auto const &s : S)
			cat = merge_cat(cat, s);
		min = std::min(min, cat.size());
	} while (next_permutation(begin(S), end(S), l));

	return min;
}

int main() {
	std::vector<std::string> S;
	for (size_t i = 0; i < N; ++i) {
		std::string x;
		std::cin >> x;
		S.push_back(std::move(x));
	}
	std::cout << solve(S) << '\n';
}


#include <cassert>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <tuple>
#include <vector>

#define STRING_IMPL(...) #__VA_ARGS__
#define STRING(...) STRING_IMPL(__VA_ARGS__)

#ifdef DEBUG
#define debug(...) void(std::cerr << "[" __FILE__ ":" STRING(__LINE__)  "] " #__VA_ARGS__ " = " << (__VA_ARGS__) << '\n')
#else
#define debug(...) void()
#endif

template <typename... Ts>
std::ostream& operator<<(std::ostream &os, std::tuple<Ts...> const &theTuple) {
    os << '(';
    std::apply([&os](Ts const&... tupleArgs) {
            std::size_t n{0};
            ((os << tupleArgs << (++n != sizeof...(Ts) ? ", " : "")), ...);
        }, theTuple);
    return os << ')';
}

template <typename T>
std::ostream& operator<< (std::ostream &os, std::vector<T> const &v) {
	os << '[';
	std::copy(begin(v), end(v), std::ostream_iterator<T>(os, ", "));
	os << "\b\b]";
	return os;
}

constexpr size_t N = 3;

std::vector<size_t> zalgo(std::string const &S) noexcept {
	size_t l = 0, r = 0;
	std::vector<size_t> Z;
	Z.reserve(S.size());
	Z.push_back(0);

	for (size_t i = 1; i < S.size(); ++i)
		if (i > r) {
			l = r = i;
			while (r < S.size() && S[r] == S[r-l])
				++r;
			Z.push_back(r - l);
		} else if (Z[i - l] > r - i) {
			l = i;
			while (r < S.size() && S[r] == S[r-l])
				++r;
			Z.push_back(r - l);
		} else {
			Z.push_back(Z[i - l]);
		}

	assert(Z.size() == S.size());
	return Z;
}

std::string merge_cat(std::string const &lhs, std::string const &rhs) {
	std::string cat = rhs + lhs;
	auto const Z = zalgo(cat);

	size_t overlapping = 0;
	for (size_t i = cat.size() - std::min(lhs.size(), rhs.size()); i < cat.size(); ++i)
		if (i + Z[i] == cat.size()) {
			overlapping = Z[i];
			break;
		}

	cat.clear();
	std::copy(begin(lhs), end(lhs), back_inserter(cat));
	std::copy(begin(rhs) + overlapping, end(rhs), back_inserter(cat));
	return cat;
}

bool contains(std::string const &a, std::string const &b) noexcept {
	auto const Z = zalgo(b + a);

	bool const ans = std::strstr(a.c_str(), b.c_str());

	for (size_t i = b.size(); i < Z.size(); ++i)
		if (Z[i] == b.size()) {
			assert(ans);
			return true;
		}

	assert(!ans);
	return false;
}

size_t solve(std::vector<std::string> &S) {
	auto min = SIZE_MAX;

	auto const l = [](std::string const &a, std::string const &b) { return a.size() != b.size() ? a.size() < b.size() : a < b; };

	sort(begin(S), end(S), l);
	for (size_t i = S.size() - 1; i < S.size(); --i)
		for (size_t j = i+1; j < S.size(); ++j)
			if (contains(S[j], S[i])) {
				S.erase(begin(S) + i);
				break;
			}

	do {
		std::string cat = "";
		for (auto const &s : S)
			cat = merge_cat(cat, s);
		min = std::min(min, cat.size());
	} while (next_permutation(begin(S), end(S), l));

	return min;
}

int main() {
	std::vector<std::string> S;
	for (size_t i = 0; i < N; ++i) {
		std::string x;
		std::cin >> x;
		S.push_back(std::move(x));
	}
	std::cout << solve(S) << '\n';
}


#include <cassert>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <tuple>
#include <vector>

#define STRING_IMPL(...) #__VA_ARGS__
#define STRING(...) STRING_IMPL(__VA_ARGS__)

#ifdef DEBUG
#define debug(...) void(std::cerr << "[" __FILE__ ":" STRING(__LINE__)  "] " #__VA_ARGS__ " = " << (__VA_ARGS__) << '\n')
#else
#define debug(...) void()
#endif

template <typename... Ts>
std::ostream& operator<<(std::ostream &os, std::tuple<Ts...> const &theTuple) {
    os << '(';
    std::apply([&os](Ts const&... tupleArgs) {
            std::size_t n{0};
            ((os << tupleArgs << (++n != sizeof...(Ts) ? ", " : "")), ...);
        }, theTuple);
    return os << ')';
}

template <typename T>
std::ostream& operator<< (std::ostream &os, std::vector<T> const &v) {
	os << '[';
	std::copy(begin(v), end(v), std::ostream_iterator<T>(os, ", "));
	os << "\b\b]";
	return os;
}

constexpr size_t N = 3;

std::vector<size_t> zalgo(std::string const &S) noexcept {
	size_t l = 0, r = 0;
	std::vector<size_t> Z;
	Z.reserve(S.size());
	Z.push_back(0);

	for (size_t i = 1; i < S.size(); ++i)
		if (i > r) {
			l = r = i;
			while (r < S.size() && S[r] == S[r-l])
				++r;
			Z.push_back(r - l);
		} else if (Z[i - l] > r - i) {
			l = i;
			while (r < S.size() && S[r] == S[r-l])
				++r;
			Z.push_back(r - l);
		} else {
			Z.push_back(Z[i - l]);
		}

	assert(Z.size() == S.size());
	return Z;
}

std::string merge_cat(std::string const &lhs, std::string const &rhs) {
	std::string cat = rhs + lhs;
	auto const Z = zalgo(cat);

	size_t overlapping = 0;
	for (size_t i = cat.size() - std::min(lhs.size(), rhs.size()); i < cat.size(); ++i)
		if (i + Z[i] == cat.size()) {
			overlapping = Z[i];
			break;
		}

	cat.clear();
	std::copy(begin(lhs), end(lhs), back_inserter(cat));
	std::copy(begin(rhs) + overlapping, end(rhs), back_inserter(cat));
	return cat;
}

bool contains(std::string const &a, std::string const &b) noexcept {
	auto const Z = zalgo(b + a);

	for (size_t i = b.size(); i < Z.size(); ++i)
		if (Z[i] == b.size())
			return true;

	return false;
}

size_t solve(std::vector<std::string> &S) {
	auto min = SIZE_MAX;

	auto const l = [](std::string const &a, std::string const &b) { return a.size() != b.size() ? a.size() < b.size() : a < b; };

	sort(begin(S), end(S), l);
	for (size_t i = S.size() - 1; i < S.size(); --i)
		for (size_t j = i+1; j < S.size(); ++j)
			if (contains(S[j], S[i])) {
				S.erase(begin(S) + i);
				break;
			}

	do {
		std::string cat = "";
		for (size_t i = 0; i < S.size(); ++i)
			cat = merge_cat(cat, S[i]);
		min = std::min(min, cat.size());

		cat = "";
		for (size_t i = S.size() - 1; i < S.size(); --i)
			cat = merge_cat(S[i], cat);
		min = std::min(min, cat.size());
	} while (next_permutation(begin(S), end(S), l));

	return min;
}

int main() {
	std::vector<std::string> S;
	for (size_t i = 0; i < N; ++i) {
		std::string x;
		std::cin >> x;
		S.push_back(std::move(x));
	}
	std::cout << solve(S) << '\n';
}


#include <cassert>
#include <iostream>
#include <iterator>
#include <vector>
#include <tuple>

#define STRING_IMPL(...) #__VA_ARGS__
#define STRING(...) STRING_IMPL(__VA_ARGS__)

#ifdef DEBUG
#define debug(...) void(std::cerr << "[" __FILE__ ":" STRING(__LINE__)  "] " #__VA_ARGS__ " = " << (__VA_ARGS__) << '\n')
#else
#define debug(...) void()
#endif

template <typename... Ts>
std::ostream& operator<<(std::ostream &os, std::tuple<Ts...> const &theTuple) {
    os << '(';
    std::apply([&os](Ts const&... tupleArgs) {
            std::size_t n{0};
            ((os << tupleArgs << (++n != sizeof...(Ts) ? ", " : "")), ...);
        }, theTuple);
    return os << ')';
}

template <typename T>
std::ostream& operator<< (std::ostream &os, std::vector<T> const &v) {
	os << '[';
	std::copy(begin(v), end(v), std::ostream_iterator<T>(os, ", "));
	os << "\b\b]";
	return os;
}

constexpr size_t N = 3;

std::string merge_cat(std::string const &lhs, std::string const &rhs) {
	std::string cat = rhs + lhs;

	std::vector<size_t> Z;
	Z.reserve(cat.size());
	Z.push_back(0);

	size_t l = 0;
	size_t r = 0;
	for (size_t i = 1; i < cat.size(); ++i)
		if (i > r) {
			l = r = i;
			while (r < cat.size() && cat[r] == cat[r-l])
				++r;
			Z.push_back(r - l);
		} else if (Z[i - l] > r - i) {
			l = i;
			while (r < cat.size() && cat[r] == cat[r-l])
				++r;
			Z.push_back(r - l);
		} else {
			Z.push_back(Z[i - l]);
		}

	assert(Z.size() == cat.size());

	size_t overlapping = 0;
	for (size_t i = cat.size() - std::min(lhs.size(), rhs.size()); i < cat.size(); ++i) {
		if (i + Z[i] == cat.size()) {
			overlapping = Z[i];
			break;
		}
	}

	cat.clear();
	std::copy(begin(lhs), end(lhs), back_inserter(cat));
	std::copy(begin(rhs) + overlapping, end(rhs), back_inserter(cat));

	return cat;
}

size_t solve(std::array<std::string, N> const &S) {
	auto min = SIZE_MAX;

	for (size_t i = 0; i < N; ++i)
		for (size_t j = 0; j < N; ++j)
			for (size_t k = 0; k < N; ++k)
				if (i != j && j != k && k != i) {
					min = std::min(min, merge_cat(merge_cat(S[i], S[j]), S[k]).size());
					min = std::min(min, merge_cat(S[i], merge_cat(S[j], S[k])).size());
				}

	return min;
}

int main() {
	std::array<std::string, N> S;
	for (auto &s : S)
		std::cin >> s;
	std::cout << solve(S) << '\n';
}