#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int a,b;
	long long int t;
	cin>>a>>b>>t;
	long long int x1;
	long long int x2;
	long long int x;
	if(t==1)
		x=b-a+1;
	else

	if(b-a<t)
		x=0;
	else
	{
		if(a%2==b%2)
		{
			x1=a/t;
			x2=b/t;
			x=x2-x1+1;
		}
		else

		{
			x1=a/t;
			x2=b/t;
			x=x2-x1;
		}
	}
	cout<<x<<endl;
	return 0;
}
