//  [javascript]
"use strict"
function Main(stdin){
stdin = stdin.trim().split("\n").reverse();
let stdout = [];
function input(){return stdin.pop()};
function print(x){stdout.push(x)};
function max(list){return list.reduce(function(a,b){ return Math.max(a,b) }) }
function min(list){return list.reduce(function(a,b){ return Math.min(a,b) }) }
function sum(list){return list.reduce(function(a,b){ return a+b }) }
function sortex(list, index){list.sort((a, b) => a[index] - b[index])}
function all(list){return list.reduce(function(a,b){ return a && b }) }
function any(list){return list.reduce(function(a,b){ return a || b }) }
function isneg(x){if(x[0]=="-"){return true}else{return false}}
function neg(x){if(isneg(x)){return x.slice(1, x.length)}else{return "-"+x}}
function equal(arr, brr){
    if (arr.length !== brr.length){ throw new Error("length not match") }
    let crr = new Array(arr.length)
    for (let i = 0; i < arr.length; i++){ crr[i] = (arr[i] === brr[i]) }
    return all(crr)
}

function zerot(x){
    let rx = Array.from(x).reverse()    
    while(rx[rx.length - 1] === "0"){
        rx.pop()
        if (rx.length === 0){
            rx = ["0"]
            break;
        }
    }
    return rx.reverse().join("")
}

function zerocut(x){
    if (isneg(x)){
        let ans = neg(zerot(neg(x)))
        if (ans === "-0"){ return "0" }
        return ans
    }else{
        return zerot(x)
    }
}

function bigsmal(x, y){
    if (isneg(x) || isneg(y)){ throw new Error("negative input") }
    if (x.length > y.length){
        return [x, y]
    }else if(x.length < y.length){
        return [y, x]
    }else{
        return [x, y].sort().reverse()
    }
}

function bigsmall(x, y){
    if (!isneg(x) && isneg(y)){
        return [x,y]
    }else if (isneg(x) && !isneg(y)){
        return [y,x]
    }else if (!isneg(x) && !isneg(y)){
        return bigsmal(x, y)
    }else if (isneg(x) && isneg(y)){
        let tmp = bigsmal(neg(x), neg(y)).reverse()
        return Array.from(tmp, i => neg(i))   
    }
}

function greater(x, y){
    if (equal(bigsmall(x, y), [x, y]) && (x !== y)){
        return true
    }else{ return false }
}

function ad(x, y){
    if (isneg(x) || isneg(y)){ throw new Error("negative input") }
    let ra = Array(Math.max(x.length, y.length) + 1).fill(0)
    let rx = Array.from(x, i => parseInt(i)).reverse()
    let ry = Array.from(y, i => parseInt(i)).reverse()
    for (let i = 0; i < rx.length; i++){ ra[i] += rx[i] }
    for (let i = 0; i < ry.length; i++){ ra[i] += ry[i] }
    for (let i = 0; i < ra.length - 1; i++){
        ra[i+1] += ra[i]/10|0
        ra[i] = ra[i] % 10
    }
    let ans = Array.from(ra, i => i+"").reverse().join("")
    return zerocut(ans)
}

function s_b(x, y){
    if (isneg(x) || isneg(y)){ throw new Error("negative input") }
    if (!equal(bigsmall(x, y), [x, y])){ throw new Error("not x>=y error") }
    let ra = Array(Math.max(x.length, y.length)).fill(0)
    let rx = Array.from(x, i => parseInt(i)).reverse()
    let ry = Array.from(y, i => parseInt(i)).reverse()
    for (let i = 0; i < rx.length; i++){ ra[i] += rx[i] }
    for (let i = 0; i < ry.length; i++){ ra[i] -= ry[i] }
    for (let i = 0; i < ra.length - 1; i++){
        if (ra[i] < 0){
            ra[i] = 10 + ra[i]
            ra[i+1] -= 1
        }
    }
    let ans = Array.from(ra, i => i+"").reverse().join("")
    return zerocut(ans)
}

function sb(x, y){
    if (isneg(x) || isneg(y)){ throw new Error("negative input") }
    if (equal(bigsmall(x, y), [x, y])){
        return s_b(x, y)
    }else{ return neg(s_b(y, x)) }
}

function add(x, y){
    if(isneg(x) && isneg(y)){
        return neg(ad(neg(x), neg(y)))
    }else if(!isneg(x) && !isneg(y)){
        return ad(x, y)
    }else if(!isneg(x) && isneg(y)){
        return sb(x, neg(y))
    }else if(isneg(x) && !isneg(y)){
        return sb(y, neg(x))
    }
}

function sub(x, y){
    if(isneg(x) && isneg(y)){
        return sb(neg(y), neg(x))
    }else if(!isneg(x) && !isneg(y)){
        return sb(x, y)
    }else if(!isneg(x) && isneg(y)){
        return ad(x, neg(y))
    }else if(isneg(x) && !isneg(y)){
        return neg(ad(neg(x), y))
    }
}

function ml(x, y){
    if (isneg(x) || isneg(y)){ throw new Error("negative input") }
    let ra = Array(x.length + y.length).fill(0)
    let rx = Array.from(x, i => parseInt(i)).reverse()
    let ry = Array.from(y, i => parseInt(i)).reverse()
    for (let i = 0; i < rx.length; i++){ 
        for (let j = 0; j < ry.length; j++){
            ra[i+j] += rx[i] * ry[j]
        }
    }
    for (let i = 0; i < ra.length - 1; i++){
        ra[i+1] += ra[i]/10|0
        ra[i] = ra[i] % 10
    }
    let ans = Array.from(ra, i => i+"").reverse().join("")
    return zerocut(ans)
}

function mul(x, y){
    if(isneg(x) && isneg(y)){
        return ml(neg(x), neg(y))
    }else if(!isneg(x) && !isneg(y)){
        return ml(x, y)
    }else if(!isneg(x) && isneg(y)){
        return zerocut(neg(ml(x, neg(y))))
    }else if(isneg(x) && !isneg(y)){
        return zerocut(neg(ml(neg(x), y)))
    }
}

function mod2(x){
    return parseInt(x[x.length-1]) % 2
}

function div2(x){
    if (isneg(x)){ throw new Error("negative input") }
    let ans = Array(x.length).fill(0)
    let xs = Array.from(x, i => parseInt(i))
    for (let i = 0; i < x.length - 1; i++){ 
        ans[i] += xs[i]
        ans[i+1] += (ans[i]%2) * 10
        ans[i] = ans[i]/2|0
    }
    ans[x.length-1] = (ans[x.length-1] + xs[x.length-1])/2|0
    ans = Array.from(ans, i => i+"").join("")
    return zerocut(ans)
}

function dv(a, b){
    if (isneg(a) || isneg(b)){ throw new Error("negative input") }
    if (b === "0"){ throw new Error("zero div error") }
    if (b === "1"){ return a }
    let left = "0"
    let right = a
    while (greater(right, add(left, "1"))){
        let x = div2(add(left, right))
        //print(x)
        if (equal([a, mul(b, x)], bigsmall(a, mul(b, x)))){
            left = x
        }else{ right = x }
    }
    return left
}

function div(x, y){
    if(isneg(x) && isneg(y)){
        return dv(neg(x), neg(y))
    }else if(!isneg(x) && !isneg(y)){
        return dv(x, y)
    }else if(!isneg(x) && isneg(y)){
        return zerocut(neg(dv(x, neg(y))))
    }else if(isneg(x) && !isneg(y)){
        return zerocut(neg(dv(neg(x), y)))
    }
}

function mod(x, y){
    if (isneg(x) || isneg(y)){ throw new Error("negative input") }
    let divmul = mul(div(x, y), y)
    return sub(x, divmul)
}

function addall(list){return list.reduce(function(a,b){ return add(a, b) }) }

function gcd(x, y){
    let tmp = bigsmall(x, y)
    let a = tmp[0]
    let b = tmp[1]
    let r = mod(a, b)
    while (r !== "0"){
        a = b
        b = r
        r = mod(a, b)
    }
    return b
}

function binarev(x){
    let ans = [];
    while(x !== "0"){
        ans.push(mod(x, "2"))
        x = div(x, "2")
    }
    return ans
}

function power(a, b, c){
    if (isneg(a) || isneg(b)){ throw new Error("negative input") }
    if (c){
        let bb = binarev(b)
        let n = bb.length
        let pool = Array(n).fill(mod(a, c))
        for (let i = 1; i < n; i++){
            pool[i] = mod(mul(pool[i-1], pool[i-1]), c)
        }
        let ans = "1"
        for (let i = 0; i < n; i++){
            if (bb[i] == "1"){ans = mod(mul(ans, pool[i]), c)}
        }  
        return ans
    }else{
        let bb = binarev(b)
        let n = bb.length
        let pool = Array(n).fill(a)
        for (let i = 1; i < n; i++){
            pool[i] = mul(pool[i-1], pool[i-1])
        }
        let ans = "1"
        for (let i = 0; i < n; i++){
            if (bb[i] == "1"){ans = mul(ans, pool[i])}
        }  
        return ans
    }
}
        
function root(x, n){
    if (isneg(x) || isneg(n)){ throw new Error("negative input") }
    if (zerocut(x) === "0"){ return "0" }
    let a = x
    let left = "0"
    let right = x
    while (greater(right, add(left, "1"))){
        x = div2(add(left, right))
        if (equal([a, power(x, n)], bigsmall(a, power(x, n)))){
            left = x
        }else{ right = x }
    }
    return left
}

function log(x, n){
    if (isneg(x) || isneg(n)){ throw new Error("negative input") }
    let a = x
    let left = "0"
    let right = x
    while (greater(right, add(left, "1"))){
        x = div2(add(left, right))
        if (equal([a, power(n, x)], bigsmall(a, power(n, x)))){
            left = x
        }else{ right = x }
    }
    return left
}

function perm(N, R, MOD){
    if (isneg(N) || isneg(R)){ throw new Error("negative input") }
    if (!equal(bigsmall(N, R), [N, R])){ throw new Error("not N>=R error") }
    let ans = "1"
    if (MOD){
        let i = add(sub(N, R), "1")
        while (i !== add(N, "1")){
            ans = mod(mul(ans, i), MOD)
            i = add(i, "1")
        }
        return ans    
    }else{
        let i = add(sub(N, R), "1")
        while (i !== add(N, "1")){
            ans = mul(ans, i)
            i = add(i, "1")
        }
        return ans
    }
}

function comb(N, R, MOD){
    if (isneg(N) || isneg(R)){ throw new Error("negative input") }
    if (!equal(bigsmall(N, R), [N, R])){ throw new Error("not N>=R error") }
    if (MOD){
        let powRR = power(perm(R,R,MOD), sub(MOD,"2"), MOD)
        return mod(mul(perm(N,R,MOD), powRR), MOD)
    }else{
        return div(perm(N, R), perm(R, R))
    }
}
/*START*/


let tmp = input().split(" ")
let a = tmp[0]
let b = tmp[1]
let x = tmp[2]
let ansA;
if (a == "0"){
    ansA = "0"
}else{
    ansA = add("1", div(sub(a, "1"), x))
}
let ansB = add("1", div(b, x))
print(sub(ansB, ansA))



/*END*/
console.log(stdout.join("\n"));
return stdout
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))