import java.io.*
import java.math.BigDecimal
import java.math.BigInteger
import java.util.StringTokenizer
import java.util.Stack
import java.util.TreeMap

object programkt {
    interface Scanner {
        fun changeInputStream(inputStream: InputStream)
        fun nextInt(): Int
        fun nextLong(): Long
        fun nextDouble(): Double
        fun nextChar(): Char
        fun nextString(): String
        fun nextLine(): String
        fun nextBigInteger(): BigInteger
        fun nextBigDecimal(): BigDecimal
    }

    abstract class Task {
        //KT Extensions
        fun <T : Comparable<T>> min(a: T, b: T) = if (a > b) b else a
        fun <T : Comparable<T>> max(a: T, b: T) = if (a < b) b else a
        fun abs(a: Int) = if (a > 0) a else -(a)
        fun abs(a: Long) = if (a > 0) a else -(a)
        fun abs(a: Float) = if (a > 0) a else -(a)
        fun abs(a: Double) = if (a > 0) a else -(a)
        operator fun <T> Iterable<T>.invoke(function: (it: T) -> Unit) { this.forEach(function) }
        private fun String.prefix(pi: Array<Int>): Array<Int> {
            pi[0] = 0
            (1 until this.length) {
                var j = pi[it - 1]
                while (j > 0 && this[it] != this[j]) {
                    j = pi[j - 1]
                }
                if(this[it] == this[j]) {
                    j++
                }
                pi[it] = j
            }
            return pi
        }
        private fun String.kmpFind(pattern: String): Int {
            val m = pattern.length
            val dfa = Array(256) { IntArray(m) }
            dfa[pattern[0].toInt()][0] = 1
            var x = 0
            var j = 1
            while (j < m) {
                for (c in 0 until 256) {
                    dfa[c][j] = dfa[c][x]        // Copy mismatch cases.
                }
                dfa[pattern[j].toInt()][j] = j + 1   // Set match case.
                x = dfa[pattern[j].toInt()][x]       // Update restart state.
                j++
            }

            val n = this.length
            var i: Int = 0
            j = 0
            while (i < n && j < m) {
                j = dfa[this[i].toInt()][j]
                i++
            }
            if (j == m) return i - m    // found
            return n                    // not found
        }
        fun fuckExceptions(invoker: () -> Unit) = try { invoker.invoke() } catch (_: Throwable) {}

        enum class EdgeType {
            DIRECTED,
            UNDIRECTED
        }
        data class Vertex<T: Comparable<T>>(
                val data: T
        ) {
            override fun toString(): String = "V:$data"
        }
        data class Edge<T:Comparable<T>>(
                var source: Vertex<T>,
                var destination: Vertex<T>,
                val weight: Double?
        )
        interface Graphable<T: Comparable<T>> {
            fun createVertex(data: T): Vertex<T>
            fun add(type: EdgeType, source: Vertex<T>, destination: Vertex<T>, weight: Double? = 0.0)
            fun weight(source: Vertex<T>, destination: Vertex<T>): Double?
            fun edges(source: Vertex<T>): MutableList<Edge<T>>?
        }
        class AdjacencyList<T: Comparable<T>>: Graphable<T> {
            var adjacencyMap: MutableMap<Vertex<T>, MutableList<Edge<T>>> = mutableMapOf()

            private fun addDirectedEdge(source: Vertex<T>, destination: Vertex<T>, weight: Double?) {
                adjacencyMap[source]?.add(Edge(source = source, destination = destination, weight = weight))
            }

            private fun addUndirectedEdge(source: Vertex<T>, destination: Vertex<T>, weight: Double?) {
                addDirectedEdge(source, destination, weight)
                addDirectedEdge(destination, source, weight)
            }

            override fun createVertex(data: T): Vertex<T> {
                val vertex = Vertex(data = data)
                adjacencyMap[vertex] ?: run {
                    adjacencyMap[vertex] = mutableListOf()
                }
                return vertex
            }

            override fun add(type: EdgeType, source: Vertex<T>, destination: Vertex<T>, weight: Double?) = when(type) {
                EdgeType.DIRECTED -> addDirectedEdge(source, destination, weight)
                EdgeType.UNDIRECTED -> addUndirectedEdge(source, destination, weight)
            }

            override fun weight(source: Vertex<T>, destination: Vertex<T>): Double? {
                adjacencyMap[source]?.forEach {
                    if(it.destination == destination) return it.weight
                }
                return null
            }

            override fun edges(source: Vertex<T>): MutableList<Edge<T>>? = adjacencyMap[source]

            override fun toString(): String {
                var result = ""
                for ((vertex, edges) in adjacencyMap) {
                    var edgeString = ""
                    for ((index, edge) in edges.withIndex()) {
                        edgeString += if (index != edges.count() - 1) "${edge.destination}, "
                        else "${edge.destination}"
                    }
                    result += "$vertex ---> [ $edgeString ] \n"
                }
                return result
            }

            fun depthFirstSearch(start: Vertex<T>, end: Vertex<T>): Stack<Vertex<T>> {
                val visited: HashSet<Vertex<T>> = hashSetOf()
                val stack: Stack<Vertex<T>> = Stack()
                stack.push(start)
                visited.add(start)

                var currentVertex = stack.peek()
                loop@while (currentVertex != null && currentVertex != end) {
                    val neighbors = edges(currentVertex)
                    if(neighbors != null && neighbors.count() > 0) {
                        for(edge in neighbors) {
                            if(!visited.contains(edge.destination)) {
                                visited.add(edge.destination)
                                stack.push(edge.destination)
                                currentVertex = stack.peek()
                                continue@loop
                            }
                        }
                    } else {
                        stack.pop()
                        currentVertex = stack.peek()
                        continue
                    }

                    stack.pop()
                    currentVertex = stack.peek()
                }

                return stack
            }

            fun breadthFirstSearch() {

            }

            fun floydWarshallAlgorythm(): Pair<Array<DoubleArray>, Array<IntArray>> {
                val nVertices = this.adjacencyMap.size

                val weights = Array(nVertices) { Array(nVertices-1) { 0.0 } }
                this.adjacencyMap
                        .asSequence()
                        .map { it.value }
                        .withIndex()
                        .forEach { (index, weightsOfVertex) ->
                            weightsOfVertex.asSequence()
                                    .withIndex()
                                    .forEach { (weightIndex, weight) ->
                                        weights[index][weightIndex] = weight.weight!!
                                    }
                        }

                val dist = Array(nVertices) { DoubleArray(nVertices) { Double.POSITIVE_INFINITY } }
                for (w in weights) dist[(w[0] - 1).toInt()][(w[1] - 1).toInt()] = w[2]
                val next = Array(nVertices) { IntArray(nVertices) }
                for (i in 0 until next.size) {
                    for (j in 0 until next.size) {
                        if (i != j) next[i][j] = j + 1
                    }
                }
                for (k in 0 until nVertices) {
                    for (i in 0 until nVertices) {
                        for (j in 0 until nVertices) {
                            if (dist[i][k] + dist[k][j] < dist[i][j]) {
                                dist[i][j] = dist[i][k] + dist[k][j]
                                next[i][j] = next[i][k]
                            }
                        }
                    }
                }
                return dist to next
            }
        }

        fun <T: Comparable<T>> TreeMap<T, Array<Double>>.toAdjacencyList(type: EdgeType): AdjacencyList<T> {
            val list = AdjacencyList<T>()

            this.keys.forEach { list.createVertex(it) }
            this.entries
                    .asSequence()
                    .withIndex()
                    .forEach { (x, edge) ->
                        val vertex = list.createVertex(edge.key)
                        edge.value
                                .asSequence()
                                .withIndex()
                                .forEach { (y, weight) ->
                                    if(weight != .0 && y != x)
                                        list.add(type, vertex, list.createVertex(this.keys.elementAt(y)), weight)
                                }
                    }
            return list
        }

        open class Point<X: Comparable<X>, Y: Comparable<Y>>(open var x: X, open var y: Y) {
            operator fun component1() = x
            operator fun component2() = y
            override fun equals(other: Any?): Boolean = when {
                other == null -> false
                other !is Point<*, *> -> false
                other.x != this.x -> false
                other.y != this.y -> false
                else -> true
            }
        }

        class IntPoint(override var x: Int, override var y: Int): Point<Int, Int>(x, y) {
            operator fun plus(point: IntPoint) = IntPoint(this.x + point.x, this.y + point.y)
            operator fun minus(point: IntPoint) = IntPoint(this.x - point.x, this.y - point.y)
            operator fun div(point: IntPoint) = IntPoint(this.x / point.x, this.y / point.y)
            operator fun times(point: IntPoint) = IntPoint(this.x * point.x, this.y * point.y)

            operator fun plus(coefficient: Int) = IntPoint(this.x + coefficient, this.y + coefficient)
            operator fun minus(coefficient: Int) = IntPoint(this.x - coefficient, this.y - coefficient)
            operator fun div(coefficient: Int) = IntPoint(this.x / coefficient, this.y / coefficient)
            operator fun times(coefficient: Int) = IntPoint(this.x * coefficient, this.y * coefficient)

            fun distanceTo(point: IntPoint) = Math.sqrt(((this.x - point.x) * (this.x - point.x) + (this.y-point.y) * (this.y - point.y)).toDouble())
        }
        class LongPoint(override var x: Long, override var y: Long): Point<Long, Long>(x, y) {
            constructor(x: Int, y: Int): this(x.toLong(), y.toLong())

            operator fun plus(point: LongPoint) = LongPoint(this.x + point.x, this.y + point.y)
            operator fun minus(point: LongPoint) = LongPoint(this.x - point.x, this.y - point.y)
            operator fun div(point: LongPoint) = LongPoint(this.x / point.x, this.y / point.y)
            operator fun times(point: LongPoint) = LongPoint(this.x * point.x, this.y * point.y)

            operator fun plus(coefficient: Long) = LongPoint(this.x + coefficient, this.y + coefficient)
            operator fun plus(coefficient: Int) = LongPoint(this.x + coefficient, this.y + coefficient)
            operator fun minus(coefficient: Long) = LongPoint(this.x - coefficient, this.y - coefficient)
            operator fun minus(coefficient: Int) = LongPoint(this.x - coefficient, this.y - coefficient)
            operator fun div(coefficient: Long) = LongPoint(this.x / coefficient, this.y / coefficient)
            operator fun div(coefficient: Int) = LongPoint(this.x / coefficient, this.y / coefficient)
            operator fun times(coefficient: Long) = LongPoint(this.x * coefficient, this.y * coefficient)
            operator fun times(coefficient: Int) = LongPoint(this.x * coefficient, this.y * coefficient)

            fun distanceTo(point: LongPoint) = Math.sqrt(((this.x - point.x) * (this.x - point.x) + (this.y-point.y) * (this.y - point.y)).toDouble())
        }
        open class DoublePoint(override var x: Double, override var y: Double): Point<Double, Double>(x, y) {
            constructor(x: Int, y: Int): this(x.toDouble(), y.toDouble())
            constructor(x: Long, y: Long): this(x.toDouble(), y.toDouble())

            operator fun plus(point: DoublePoint) = DoublePoint(this.x + point.x, this.y + point.y)
            operator fun minus(point: DoublePoint) = DoublePoint(this.x - point.x, this.y - point.y)
            operator fun div(point: DoublePoint) = DoublePoint(this.x / point.x, this.y / point.y)
            operator fun times(point: DoublePoint) = DoublePoint(this.x * point.x, this.y * point.y)

            operator fun plus(coefficient: Double) = DoublePoint(this.x + coefficient, this.y + coefficient)
            operator fun plus(coefficient: Long) = DoublePoint(this.x + coefficient, this.y + coefficient)
            operator fun plus(coefficient: Int) = DoublePoint(this.x + coefficient, this.y + coefficient)
            operator fun minus(coefficient: Double) = DoublePoint(this.x - coefficient, this.y - coefficient)
            operator fun minus(coefficient: Long) = DoublePoint(this.x - coefficient, this.y - coefficient)
            operator fun minus(coefficient: Int) = DoublePoint(this.x - coefficient, this.y - coefficient)
            operator fun div(coefficient: Double) = DoublePoint(this.x / coefficient, this.y / coefficient)
            operator fun div(coefficient: Long) = DoublePoint(this.x / coefficient, this.y / coefficient)
            operator fun div(coefficient: Int) = DoublePoint(this.x / coefficient, this.y / coefficient)
            operator fun times(coefficient: Double) = DoublePoint(this.x * coefficient, this.y * coefficient)
            operator fun times(coefficient: Long) = DoublePoint(this.x * coefficient, this.y * coefficient)
            operator fun times(coefficient: Int) = DoublePoint(this.x * coefficient, this.y * coefficient)

            fun distanceTo(point: DoublePoint) = Math.sqrt(((this.x - point.x) * (this.x - point.x) + (this.y-point.y) * (this.y - point.y)))
            fun polarAngle(): Double {
                val minPolarAngle = Math.atan2(y, x)
                return if(minPolarAngle < 0) minPolarAngle + 2 * Math.PI else minPolarAngle
            }
        }
        class Vector(x: Double, y: Double): DoublePoint(x, y) {
            constructor(x: Int, y: Int): this(x.toDouble(), y.toDouble())
            constructor(x: Long, y: Long): this(x.toDouble(), y.toDouble())

            fun length() = Math.sqrt(x*x + y*y)
            fun angleTo(vector: Vector): Double {
                val temp = this * vector
                return Math.acos((temp.x + temp.y) / this.length() / vector.length())
            }
        }
        //End KT Extensions

        abstract fun solve(scanner: Scanner, printer: PrintWriter)
    }

    class FastScanner: Scanner {
        var inputStream: InputStream? = null
        override fun changeInputStream(inputStream: InputStream) {
            this.inputStream = inputStream
            this.bufferedReader = BufferedReader(InputStreamReader(inputStream))
        }

        private lateinit var bufferedReader: BufferedReader
        private var stringTokenizer: StringTokenizer? = null

        private fun nextToken(): String? {
            while (stringTokenizer == null || !stringTokenizer!!.hasMoreTokens())
                stringTokenizer = StringTokenizer(bufferedReader.readLine() ?: return null)
            return stringTokenizer!!.nextToken()
        }

        override fun nextInt() = nextToken()!!.toInt()
        override fun nextLong() = nextToken()!!.toLong()
        override fun nextDouble() = nextToken()!!.toDouble()
        override fun nextChar() = bufferedReader.read().toChar()
        override fun nextString() = nextToken()!!
        override fun nextLine() = bufferedReader.readLine()!!
        override fun nextBigInteger() = BigInteger(nextToken()!!)
        override fun nextBigDecimal() = BigDecimal(nextToken()!!)
    }

    class TaskBuilder {
        private var task: Task? = null
        private var inputStream: InputStream? = null
        private var outputStream: OutputStream? = null
        private var scanner: Scanner? = null

        fun useInputSource(inputStream: InputStream): TaskBuilder {
            this.inputStream = inputStream
            return this
        }

        fun useOutputSource(outputStream: OutputStream): TaskBuilder {
            this.outputStream = outputStream
            return this
        }

        fun useInputFile(inputFileName: String): TaskBuilder {
            this.inputStream = FileInputStream(File(inputFileName))
            return this
        }

        fun useOutputFile(outputFileName: String): TaskBuilder {
            this.outputStream = FileOutputStream(File(outputFileName))
            return this
        }

        fun useScanner(scanner: Scanner): TaskBuilder {
            this.scanner = scanner
            return this
        }

        fun solveTask(task: Task): TaskBuilder {
            this.task = task
            return this
        }

        fun run() {
            when {
                task == null -> throw NullPointerException("Task cannot be null!")
                inputStream == null -> throw NullPointerException("Input cannot be null!")
                outputStream == null -> throw NullPointerException("Output cannot be null!")
                scanner == null -> throw NullPointerException("Scanner cannot be null!")
            }
            scanner!!.changeInputStream(inputStream!!)
            val printer = PrintWriter(outputStream)
            TaskRunnable(task!!, scanner!!, printer).run()

            inputStream!!.close()
            printer.close()
        }

        class TaskRunnable(
                private val task: Task,
                private val scanner: Scanner,
                private val printer: PrintWriter
        ) {
            fun run() {
                task.solve(scanner, printer)
            }
        }
    }

    @JvmStatic
    fun main(args: Array<String>) = TaskBuilder()
//            .useInputSource(BufferedInputStream(FileInputStream("area1.in")))
//            .useOutputSource(BufferedOutputStream(FileOutputStream("area1.out")))
            .useInputSource(System.`in`)
            .useOutputSource(System.out)
            .useScanner(FastScanner())
            .solveTask(TaskF())
            .run()

    class TaskA: Task() {
        override fun solve(scanner: Scanner, printer: PrintWriter) {
            val length = scanner.nextInt()
            val numbers = Array(length) { scanner.nextInt() }

            var maxOnesCount = -1

            (0 until length) { i ->
                (i until length) { j ->
                    var currentCountOfOnes = 0
                    (0 until length) {
                        currentCountOfOnes += if((it in (i..j) && 1 - numbers[it] == 1) || (it !in (i..j) && numbers[it] == 1)) 1 else 0 }
                    maxOnesCount = max(maxOnesCount, currentCountOfOnes)
                }
            }

            printer.println(maxOnesCount)
        }

    }

    class TaskD: Task() {
        override fun solve(scanner: Scanner, printer: PrintWriter) {
            val length = scanner.nextLong()
            (length until 2 * length) { printer.print("$it ") }
        }

    }

    class TaskE: Task() {
        override fun solve(scanner: Scanner, printer: PrintWriter) {
            val length = scanner.nextInt()
            val lineLengths = Array(length) { scanner.nextInt() }
            lineLengths.sort()
            for(it in (2 until length))
                if(lineLengths[it-2] + lineLengths[it-1] > lineLengths[it]) {
                    printer.println("YES")
                    return
                }
            printer.println("NO")
        }

    }

    class TaskF: Task() {
        override fun solve(scanner: Scanner, printer: PrintWriter) {
            val (start, check, delta) = scanner.nextLine()
                    .split(" ")
                    .map { it.toLong() }
            when {
                check < start && delta > 0 -> printer.println("NO")
                check > start && delta < 0 -> printer.println("NO")
                delta == 0L && start != check -> printer.println("NO")
                delta == 0L && start == check -> printer.println("YES")
                (check - start) % delta == 0L -> printer.println("YES")
                else -> printer.println("NO")
            }
        }

    }

}

import java.io.PrintWriter
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.math.*

val n = 0
val m = 0
fun valid(i: Int, j: Int): Boolean {
    return i in 0 until n && j in 0 until m
}

fun sumRow(arr: IntArray): Int {
    var sum = 0
    for (element in arr) sum += element
    return sum
}

fun sumCol(twoDArr: Array<IntArray>, colNumber: Int): Int {
    var sum = 0
    for (element in twoDArr) {
        sum += element[colNumber]
    }
    return sum
}

@JvmField
val INPUT = System.`in`
@JvmField
val OUTPUT = System.out

@JvmField
val _reader = INPUT.bufferedReader()

fun readLine(): String? = _reader.readLine()!!
fun readLn() = _reader.readLine()!!
@JvmField
var _tokenizer: StringTokenizer = StringTokenizer("")

fun read(): String {
    while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return "", " ")
    return _tokenizer.nextToken()
}

fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }.toMutableList().toLongArray()

@JvmField
val _writer = PrintWriter(OUTPUT, false)

inline fun output(block: PrintWriter.() -> Unit) {
    _writer.apply(block).flush()
}

fun printArr(arr: IntArray, start: Int, end: Int) {
    for (i in start..end) {
        print("${arr[i]} ")
    }
    println()
}

fun printArr(arr: LongArray, start: Int, end: Int) {
    for (i in start..end) {
        print("${arr[i]} ")
    }
    println()
}

fun main() {
    val (a, b, c) = readLongs(3)
    if (a == b) println("YES")
    else if (a < b && c > 0) if (c == 1L) println("YES") else println(if ((b - a) % c == 0L) "YES" else "NO")
    else if (a > b && c < 0) if (c == -1L) println("YES") else println(if ((b - a) % c == 0L) "YES" else "NO")
    else println("NO")
    //TODO("KYS")
}

fun main() {
    val r = System.`in`.bufferedReader()
    val s1 = StringBuilder()
    //val (s, n) = r.readLine()!!.split(" ").map { it.toInt() }
    //val n = r.readLine()!!.toInt()
    val (a, b, c) = r.readLine()!!.split(" ").map { it.toLong() }
    when {
        c == 0L && a != b -> println("NO")
        c == 0L -> println("YES")
        else -> println(if ((b - a) % c == 0L && ((b >= a&&c>0)||(b<=a&&c<0))) "YES" else "NO")
    }
}

import java.util.*

fun main(args: Array<String>) {
    val reader = Scanner(System.`in`)
    val initial = reader.nextLong()
    val desired = reader.nextLong()
    val seq = reader.nextLong()
    if (desired - initial == 0L) {
        println("YES")
        return
    }
    if (seq == 0L) {
        println("NO")
        return
    }
    if ((desired - initial) % seq == 0L && ((desired - initial) / seq) > 0)
        println("YES")
    else println("NO")
}

fun main() {
    val (a, b, c) = readLine()!!.split(" ").map(String::toLong)
    print(when {
        a == b -> "YES"
        c == 0L -> "NO"
        b > a && c < 0 -> "NO"
        b < a && c > 0 -> "NO"
        (b - a) % c == 0L -> "YES"
        else -> "NO"
    })
}

fun main() {
    val r = System.`in`.bufferedReader()
    val s1 = StringBuilder()
    //val (s, n) = r.readLine()!!.split(" ").map { it.toInt() }
    //val n = r.readLine()!!.toInt()
    val (a, b, c) = r.readLine()!!.split(" ").map { it.toLong() }
    when {
        c == 0L && a != b -> println("NO")
        c == 0L -> println("YES")
        else -> println(if ((b - a) % c == 0L) "YES" else "NO")
    }
}

fun main() {
    val r = System.`in`.bufferedReader()
    val s1 = StringBuilder()
    //val (s, n) = r.readLine()!!.split(" ").map { it.toInt() }
    //val n = r.readLine()!!.toInt()
    val (a, b, c) = r.readLine()!!.split(" ").map { it.toLong() }
    if (c == 0L) println("NO") else
        println(if ((b - a) % c == 0L) "YES" else "NO")
}

import java.io.*
import java.math.BigDecimal
import java.math.BigInteger
import java.util.StringTokenizer
import java.util.Stack
import java.util.TreeMap

object programkt {
    interface Scanner {
        fun changeInputStream(inputStream: InputStream)
        fun nextInt(): Int
        fun nextLong(): Long
        fun nextDouble(): Double
        fun nextChar(): Char
        fun nextString(): String
        fun nextLine(): String
        fun nextBigInteger(): BigInteger
        fun nextBigDecimal(): BigDecimal
    }

    abstract class Task {
        //KT Extensions
        fun <T : Comparable<T>> min(a: T, b: T) = if (a > b) b else a
        fun <T : Comparable<T>> max(a: T, b: T) = if (a < b) b else a
        fun abs(a: Int) = if (a > 0) a else -(a)
        fun abs(a: Long) = if (a > 0) a else -(a)
        fun abs(a: Float) = if (a > 0) a else -(a)
        fun abs(a: Double) = if (a > 0) a else -(a)
        operator fun <T> Iterable<T>.invoke(function: (it: T) -> Unit) { this.forEach(function) }
        private fun String.prefix(pi: Array<Int>): Array<Int> {
            pi[0] = 0
            (1 until this.length) {
                var j = pi[it - 1]
                while (j > 0 && this[it] != this[j]) {
                    j = pi[j - 1]
                }
                if(this[it] == this[j]) {
                    j++
                }
                pi[it] = j
            }
            return pi
        }
        private fun String.kmpFind(pattern: String): Int {
            val m = pattern.length
            val dfa = Array(256) { IntArray(m) }
            dfa[pattern[0].toInt()][0] = 1
            var x = 0
            var j = 1
            while (j < m) {
                for (c in 0 until 256) {
                    dfa[c][j] = dfa[c][x]        // Copy mismatch cases.
                }
                dfa[pattern[j].toInt()][j] = j + 1   // Set match case.
                x = dfa[pattern[j].toInt()][x]       // Update restart state.
                j++
            }

            val n = this.length
            var i: Int = 0
            j = 0
            while (i < n && j < m) {
                j = dfa[this[i].toInt()][j]
                i++
            }
            if (j == m) return i - m    // found
            return n                    // not found
        }
        fun fuckExceptions(invoker: () -> Unit) = try { invoker.invoke() } catch (_: Throwable) {}

        enum class EdgeType {
            DIRECTED,
            UNDIRECTED
        }
        data class Vertex<T: Comparable<T>>(
                val data: T
        ) {
            override fun toString(): String = "V:$data"
        }
        data class Edge<T:Comparable<T>>(
                var source: Vertex<T>,
                var destination: Vertex<T>,
                val weight: Double?
        )
        interface Graphable<T: Comparable<T>> {
            fun createVertex(data: T): Vertex<T>
            fun add(type: EdgeType, source: Vertex<T>, destination: Vertex<T>, weight: Double? = 0.0)
            fun weight(source: Vertex<T>, destination: Vertex<T>): Double?
            fun edges(source: Vertex<T>): MutableList<Edge<T>>?
        }
        class AdjacencyList<T: Comparable<T>>: Graphable<T> {
            var adjacencyMap: MutableMap<Vertex<T>, MutableList<Edge<T>>> = mutableMapOf()

            private fun addDirectedEdge(source: Vertex<T>, destination: Vertex<T>, weight: Double?) {
                adjacencyMap[source]?.add(Edge(source = source, destination = destination, weight = weight))
            }

            private fun addUndirectedEdge(source: Vertex<T>, destination: Vertex<T>, weight: Double?) {
                addDirectedEdge(source, destination, weight)
                addDirectedEdge(destination, source, weight)
            }

            override fun createVertex(data: T): Vertex<T> {
                val vertex = Vertex(data = data)
                adjacencyMap[vertex] ?: run {
                    adjacencyMap[vertex] = mutableListOf()
                }
                return vertex
            }

            override fun add(type: EdgeType, source: Vertex<T>, destination: Vertex<T>, weight: Double?) = when(type) {
                EdgeType.DIRECTED -> addDirectedEdge(source, destination, weight)
                EdgeType.UNDIRECTED -> addUndirectedEdge(source, destination, weight)
            }

            override fun weight(source: Vertex<T>, destination: Vertex<T>): Double? {
                adjacencyMap[source]?.forEach {
                    if(it.destination == destination) return it.weight
                }
                return null
            }

            override fun edges(source: Vertex<T>): MutableList<Edge<T>>? = adjacencyMap[source]

            override fun toString(): String {
                var result = ""
                for ((vertex, edges) in adjacencyMap) {
                    var edgeString = ""
                    for ((index, edge) in edges.withIndex()) {
                        edgeString += if (index != edges.count() - 1) "${edge.destination}, "
                        else "${edge.destination}"
                    }
                    result += "$vertex ---> [ $edgeString ] \n"
                }
                return result
            }

            fun depthFirstSearch(start: Vertex<T>, end: Vertex<T>): Stack<Vertex<T>> {
                val visited: HashSet<Vertex<T>> = hashSetOf()
                val stack: Stack<Vertex<T>> = Stack()
                stack.push(start)
                visited.add(start)

                var currentVertex = stack.peek()
                loop@while (currentVertex != null && currentVertex != end) {
                    val neighbors = edges(currentVertex)
                    if(neighbors != null && neighbors.count() > 0) {
                        for(edge in neighbors) {
                            if(!visited.contains(edge.destination)) {
                                visited.add(edge.destination)
                                stack.push(edge.destination)
                                currentVertex = stack.peek()
                                continue@loop
                            }
                        }
                    } else {
                        stack.pop()
                        currentVertex = stack.peek()
                        continue
                    }

                    stack.pop()
                    currentVertex = stack.peek()
                }

                return stack
            }

            fun breadthFirstSearch() {

            }

            fun floydWarshallAlgorythm(): Pair<Array<DoubleArray>, Array<IntArray>> {
                val nVertices = this.adjacencyMap.size

                val weights = Array(nVertices) { Array(nVertices-1) { 0.0 } }
                this.adjacencyMap
                        .asSequence()
                        .map { it.value }
                        .withIndex()
                        .forEach { (index, weightsOfVertex) ->
                            weightsOfVertex.asSequence()
                                    .withIndex()
                                    .forEach { (weightIndex, weight) ->
                                        weights[index][weightIndex] = weight.weight!!
                                    }
                        }

                val dist = Array(nVertices) { DoubleArray(nVertices) { Double.POSITIVE_INFINITY } }
                for (w in weights) dist[(w[0] - 1).toInt()][(w[1] - 1).toInt()] = w[2]
                val next = Array(nVertices) { IntArray(nVertices) }
                for (i in 0 until next.size) {
                    for (j in 0 until next.size) {
                        if (i != j) next[i][j] = j + 1
                    }
                }
                for (k in 0 until nVertices) {
                    for (i in 0 until nVertices) {
                        for (j in 0 until nVertices) {
                            if (dist[i][k] + dist[k][j] < dist[i][j]) {
                                dist[i][j] = dist[i][k] + dist[k][j]
                                next[i][j] = next[i][k]
                            }
                        }
                    }
                }
                return dist to next
            }
        }

        fun <T: Comparable<T>> TreeMap<T, Array<Double>>.toAdjacencyList(type: EdgeType): AdjacencyList<T> {
            val list = AdjacencyList<T>()

            this.keys.forEach { list.createVertex(it) }
            this.entries
                    .asSequence()
                    .withIndex()
                    .forEach { (x, edge) ->
                        val vertex = list.createVertex(edge.key)
                        edge.value
                                .asSequence()
                                .withIndex()
                                .forEach { (y, weight) ->
                                    if(weight != .0 && y != x)
                                        list.add(type, vertex, list.createVertex(this.keys.elementAt(y)), weight)
                                }
                    }
            return list
        }

        open class Point<X: Comparable<X>, Y: Comparable<Y>>(open var x: X, open var y: Y) {
            operator fun component1() = x
            operator fun component2() = y
            override fun equals(other: Any?): Boolean = when {
                other == null -> false
                other !is Point<*, *> -> false
                other.x != this.x -> false
                other.y != this.y -> false
                else -> true
            }
        }

        class IntPoint(override var x: Int, override var y: Int): Point<Int, Int>(x, y) {
            operator fun plus(point: IntPoint) = IntPoint(this.x + point.x, this.y + point.y)
            operator fun minus(point: IntPoint) = IntPoint(this.x - point.x, this.y - point.y)
            operator fun div(point: IntPoint) = IntPoint(this.x / point.x, this.y / point.y)
            operator fun times(point: IntPoint) = IntPoint(this.x * point.x, this.y * point.y)

            operator fun plus(coefficient: Int) = IntPoint(this.x + coefficient, this.y + coefficient)
            operator fun minus(coefficient: Int) = IntPoint(this.x - coefficient, this.y - coefficient)
            operator fun div(coefficient: Int) = IntPoint(this.x / coefficient, this.y / coefficient)
            operator fun times(coefficient: Int) = IntPoint(this.x * coefficient, this.y * coefficient)

            fun distanceTo(point: IntPoint) = Math.sqrt(((this.x - point.x) * (this.x - point.x) + (this.y-point.y) * (this.y - point.y)).toDouble())
        }
        class LongPoint(override var x: Long, override var y: Long): Point<Long, Long>(x, y) {
            constructor(x: Int, y: Int): this(x.toLong(), y.toLong())

            operator fun plus(point: LongPoint) = LongPoint(this.x + point.x, this.y + point.y)
            operator fun minus(point: LongPoint) = LongPoint(this.x - point.x, this.y - point.y)
            operator fun div(point: LongPoint) = LongPoint(this.x / point.x, this.y / point.y)
            operator fun times(point: LongPoint) = LongPoint(this.x * point.x, this.y * point.y)

            operator fun plus(coefficient: Long) = LongPoint(this.x + coefficient, this.y + coefficient)
            operator fun plus(coefficient: Int) = LongPoint(this.x + coefficient, this.y + coefficient)
            operator fun minus(coefficient: Long) = LongPoint(this.x - coefficient, this.y - coefficient)
            operator fun minus(coefficient: Int) = LongPoint(this.x - coefficient, this.y - coefficient)
            operator fun div(coefficient: Long) = LongPoint(this.x / coefficient, this.y / coefficient)
            operator fun div(coefficient: Int) = LongPoint(this.x / coefficient, this.y / coefficient)
            operator fun times(coefficient: Long) = LongPoint(this.x * coefficient, this.y * coefficient)
            operator fun times(coefficient: Int) = LongPoint(this.x * coefficient, this.y * coefficient)

            fun distanceTo(point: LongPoint) = Math.sqrt(((this.x - point.x) * (this.x - point.x) + (this.y-point.y) * (this.y - point.y)).toDouble())
        }
        open class DoublePoint(override var x: Double, override var y: Double): Point<Double, Double>(x, y) {
            constructor(x: Int, y: Int): this(x.toDouble(), y.toDouble())
            constructor(x: Long, y: Long): this(x.toDouble(), y.toDouble())

            operator fun plus(point: DoublePoint) = DoublePoint(this.x + point.x, this.y + point.y)
            operator fun minus(point: DoublePoint) = DoublePoint(this.x - point.x, this.y - point.y)
            operator fun div(point: DoublePoint) = DoublePoint(this.x / point.x, this.y / point.y)
            operator fun times(point: DoublePoint) = DoublePoint(this.x * point.x, this.y * point.y)

            operator fun plus(coefficient: Double) = DoublePoint(this.x + coefficient, this.y + coefficient)
            operator fun plus(coefficient: Long) = DoublePoint(this.x + coefficient, this.y + coefficient)
            operator fun plus(coefficient: Int) = DoublePoint(this.x + coefficient, this.y + coefficient)
            operator fun minus(coefficient: Double) = DoublePoint(this.x - coefficient, this.y - coefficient)
            operator fun minus(coefficient: Long) = DoublePoint(this.x - coefficient, this.y - coefficient)
            operator fun minus(coefficient: Int) = DoublePoint(this.x - coefficient, this.y - coefficient)
            operator fun div(coefficient: Double) = DoublePoint(this.x / coefficient, this.y / coefficient)
            operator fun div(coefficient: Long) = DoublePoint(this.x / coefficient, this.y / coefficient)
            operator fun div(coefficient: Int) = DoublePoint(this.x / coefficient, this.y / coefficient)
            operator fun times(coefficient: Double) = DoublePoint(this.x * coefficient, this.y * coefficient)
            operator fun times(coefficient: Long) = DoublePoint(this.x * coefficient, this.y * coefficient)
            operator fun times(coefficient: Int) = DoublePoint(this.x * coefficient, this.y * coefficient)

            fun distanceTo(point: DoublePoint) = Math.sqrt(((this.x - point.x) * (this.x - point.x) + (this.y-point.y) * (this.y - point.y)))
            fun polarAngle(): Double {
                val minPolarAngle = Math.atan2(y, x)
                return if(minPolarAngle < 0) minPolarAngle + 2 * Math.PI else minPolarAngle
            }
        }
        class Vector(x: Double, y: Double): DoublePoint(x, y) {
            constructor(x: Int, y: Int): this(x.toDouble(), y.toDouble())
            constructor(x: Long, y: Long): this(x.toDouble(), y.toDouble())

            fun length() = Math.sqrt(x*x + y*y)
            fun angleTo(vector: Vector): Double {
                val temp = this * vector
                return Math.acos((temp.x + temp.y) / this.length() / vector.length())
            }
        }
        //End KT Extensions

        abstract fun solve(scanner: Scanner, printer: PrintWriter)
    }

    class FastScanner: Scanner {
        var inputStream: InputStream? = null
        override fun changeInputStream(inputStream: InputStream) {
            this.inputStream = inputStream
            this.bufferedReader = BufferedReader(InputStreamReader(inputStream))
        }

        private lateinit var bufferedReader: BufferedReader
        private var stringTokenizer: StringTokenizer? = null

        private fun nextToken(): String? {
            while (stringTokenizer == null || !stringTokenizer!!.hasMoreTokens())
                stringTokenizer = StringTokenizer(bufferedReader.readLine() ?: return null)
            return stringTokenizer!!.nextToken()
        }

        override fun nextInt() = nextToken()!!.toInt()
        override fun nextLong() = nextToken()!!.toLong()
        override fun nextDouble() = nextToken()!!.toDouble()
        override fun nextChar() = bufferedReader.read().toChar()
        override fun nextString() = nextToken()!!
        override fun nextLine() = bufferedReader.readLine()!!
        override fun nextBigInteger() = BigInteger(nextToken()!!)
        override fun nextBigDecimal() = BigDecimal(nextToken()!!)
    }

    class TaskBuilder {
        private var task: Task? = null
        private var inputStream: InputStream? = null
        private var outputStream: OutputStream? = null
        private var scanner: Scanner? = null

        fun useInputSource(inputStream: InputStream): TaskBuilder {
            this.inputStream = inputStream
            return this
        }

        fun useOutputSource(outputStream: OutputStream): TaskBuilder {
            this.outputStream = outputStream
            return this
        }

        fun useInputFile(inputFileName: String): TaskBuilder {
            this.inputStream = FileInputStream(File(inputFileName))
            return this
        }

        fun useOutputFile(outputFileName: String): TaskBuilder {
            this.outputStream = FileOutputStream(File(outputFileName))
            return this
        }

        fun useScanner(scanner: Scanner): TaskBuilder {
            this.scanner = scanner
            return this
        }

        fun solveTask(task: Task): TaskBuilder {
            this.task = task
            return this
        }

        fun run() {
            when {
                task == null -> throw NullPointerException("Task cannot be null!")
                inputStream == null -> throw NullPointerException("Input cannot be null!")
                outputStream == null -> throw NullPointerException("Output cannot be null!")
                scanner == null -> throw NullPointerException("Scanner cannot be null!")
            }
            scanner!!.changeInputStream(inputStream!!)
            val printer = PrintWriter(outputStream)
            TaskRunnable(task!!, scanner!!, printer).run()

            inputStream!!.close()
            printer.close()
        }

        class TaskRunnable(
                private val task: Task,
                private val scanner: Scanner,
                private val printer: PrintWriter
        ) {
            fun run() {
                task.solve(scanner, printer)
            }
        }
    }

    @JvmStatic
    fun main(args: Array<String>) = TaskBuilder()
//            .useInputSource(BufferedInputStream(FileInputStream("area1.in")))
//            .useOutputSource(BufferedOutputStream(FileOutputStream("area1.out")))
            .useInputSource(System.`in`)
            .useOutputSource(System.out)
            .useScanner(FastScanner())
            .solveTask(TaskF())
            .run()

    class TaskA: Task() {
        override fun solve(scanner: Scanner, printer: PrintWriter) {
            val length = scanner.nextInt()
            val numbers = Array(length) { scanner.nextInt() }

            var maxOnesCount = -1

            (0 until length) { i ->
                (i until length) { j ->
                    var currentCountOfOnes = 0
                    (0 until length) {
                        currentCountOfOnes += if((it in (i..j) && 1 - numbers[it] == 1) || (it !in (i..j) && numbers[it] == 1)) 1 else 0 }
                    maxOnesCount = max(maxOnesCount, currentCountOfOnes)
                }
            }

            printer.println(maxOnesCount)
        }

    }

    class TaskD: Task() {
        override fun solve(scanner: Scanner, printer: PrintWriter) {
            val length = scanner.nextLong()
            (length until 2 * length) { printer.print("$it ") }
        }

    }

    class TaskE: Task() {
        override fun solve(scanner: Scanner, printer: PrintWriter) {
            val length = scanner.nextInt()
            val lineLengths = Array(length) { scanner.nextInt() }
            lineLengths.sort()
            for(it in (2 until length))
                if(lineLengths[it-2] + lineLengths[it-1] > lineLengths[it]) {
                    printer.println("YES")
                    return
                }
            printer.println("NO")
        }

    }

    class TaskF: Task() {
        override fun solve(scanner: Scanner, printer: PrintWriter) {
            val (start, check, delta) = scanner.nextLine()
                    .split(" ")
                    .map { it.toLong() }
            when {
                check < start -> printer.println("NO")
                delta == 0L && start == check -> printer.println("YES")
                (check - start) % delta == 0L -> printer.println("YES")
                else -> printer.println("NO")
            }
        }

    }

}

import java.io.PrintWriter
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.math.*

val n = 0
val m = 0
fun valid(i: Int, j: Int): Boolean {
    return i in 0 until n && j in 0 until m
}

fun sumRow(arr: IntArray): Int {
    var sum = 0
    for (element in arr) sum += element
    return sum
}

fun sumCol(twoDArr: Array<IntArray>, colNumber: Int): Int {
    var sum = 0
    for (element in twoDArr) {
        sum += element[colNumber]
    }
    return sum
}

@JvmField
val INPUT = System.`in`
@JvmField
val OUTPUT = System.out

@JvmField
val _reader = INPUT.bufferedReader()

fun readLine(): String? = _reader.readLine()!!
fun readLn() = _reader.readLine()!!
@JvmField
var _tokenizer: StringTokenizer = StringTokenizer("")

fun read(): String {
    while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return "", " ")
    return _tokenizer.nextToken()
}

fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }.toMutableList().toLongArray()

@JvmField
val _writer = PrintWriter(OUTPUT, false)

inline fun output(block: PrintWriter.() -> Unit) {
    _writer.apply(block).flush()
}

fun printArr(arr: IntArray, start: Int, end: Int) {
    for (i in start..end) {
        print("${arr[i]} ")
    }
    println()
}

fun printArr(arr: LongArray, start: Int, end: Int) {
    for (i in start..end) {
        print("${arr[i]} ")
    }
    println()
}

fun main() {
    val (a, b, c) = readLongs(3)
    if (a == b) println("YES")
    else if (a < b && c > 0) if (c == 1L) println("YES") else println(if ((b - a) % c == 0L) "YES" else "NO")
    else if (a > b && c < 0) if (c == -1L) println("NO") else println(if ((b - a) % c == 0L) "YES" else "NO")
    else println("NO")
    //TODO("KYS")
}

import java.io.PrintWriter
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.math.*

val n = 0
val m = 0
fun valid(i: Int, j: Int): Boolean {
    return i in 0 until n && j in 0 until m
}

fun sumRow(arr: IntArray): Int {
    var sum = 0
    for (element in arr) sum += element
    return sum
}

fun sumCol(twoDArr: Array<IntArray>, colNumber: Int): Int {
    var sum = 0
    for (element in twoDArr) {
        sum += element[colNumber]
    }
    return sum
}

@JvmField
val INPUT = System.`in`
@JvmField
val OUTPUT = System.out

@JvmField
val _reader = INPUT.bufferedReader()

fun readLine(): String? = _reader.readLine()!!
fun readLn() = _reader.readLine()!!
@JvmField
var _tokenizer: StringTokenizer = StringTokenizer("")

fun read(): String {
    while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return "", " ")
    return _tokenizer.nextToken()
}

fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }.toMutableList().toLongArray()

@JvmField
val _writer = PrintWriter(OUTPUT, false)

inline fun output(block: PrintWriter.() -> Unit) {
    _writer.apply(block).flush()
}

fun printArr(arr: IntArray, start: Int, end: Int) {
    for (i in start..end) {
        print("${arr[i]} ")
    }
    println()
}

fun printArr(arr: LongArray, start: Int, end: Int) {
    for (i in start..end) {
        print("${arr[i]} ")
    }
    println()
}

fun main() {
    val (a, b, c) = readInts(3)
    if (a == b) println("YES")
    else if (a < c && b > 0) if (b == 1) println("YES") else println(if ((b - a) % c == 0) "YES" else "NO")
    else if (a > c && b < 0) if (b == -1) println("NO") else println(if ((b - a) % c == 0) "YES" else "NO")
    else println("NO")
    //TODO("KYS")
}

import java.io.PrintWriter
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.math.*

val n = 0
val m = 0
fun valid(i: Int, j: Int): Boolean {
    return i in 0 until n && j in 0 until m
}

fun sumRow(arr: IntArray): Int {
    var sum = 0
    for (element in arr) sum += element
    return sum
}

fun sumCol(twoDArr: Array<IntArray>, colNumber: Int): Int {
    var sum = 0
    for (element in twoDArr) {
        sum += element[colNumber]
    }
    return sum
}

@JvmField
val INPUT = System.`in`
@JvmField
val OUTPUT = System.out

@JvmField
val _reader = INPUT.bufferedReader()

fun readLine(): String? = _reader.readLine()!!
fun readLn() = _reader.readLine()!!
@JvmField
var _tokenizer: StringTokenizer = StringTokenizer("")

fun read(): String {
    while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return "", " ")
    return _tokenizer.nextToken()
}

fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }.toMutableList().toLongArray()

@JvmField
val _writer = PrintWriter(OUTPUT, false)

inline fun output(block: PrintWriter.() -> Unit) {
    _writer.apply(block).flush()
}

fun printArr(arr: IntArray, start: Int, end: Int) {
    for (i in start..end) {
        print("${arr[i]} ")
    }
    println()
}

fun printArr(arr: LongArray, start: Int, end: Int) {
    for (i in start..end) {
        print("${arr[i]} ")
    }
    println()
}

fun main() {
    val (a, b, c) = readLongs(3)
    if (a == b) println("YES")
    else if (a < c && b > 0) if (b == 1L) println("YES") else println(if ((b - a) % c == 0L) "YES" else "NO")
    else if (a > c && b < 0) if (b == -1L) println("NO") else println(if ((b - a) % c == 0L) "YES" else "NO")
    else println("NO")
    //TODO("KYS")
}

import java.io.PrintWriter
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.math.*

val n = 0
val m = 0
fun valid(i: Int, j: Int): Boolean {
    return i in 0 until n && j in 0 until m
}

fun sumRow(arr: IntArray): Int {
    var sum = 0
    for (element in arr) sum += element
    return sum
}

fun sumCol(twoDArr: Array<IntArray>, colNumber: Int): Int {
    var sum = 0
    for (element in twoDArr) {
        sum += element[colNumber]
    }
    return sum
}

@JvmField
val INPUT = System.`in`
@JvmField
val OUTPUT = System.out

@JvmField
val _reader = INPUT.bufferedReader()

fun readLine(): String? = _reader.readLine()!!
fun readLn() = _reader.readLine()!!
@JvmField
var _tokenizer: StringTokenizer = StringTokenizer("")

fun read(): String {
    while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return "", " ")
    return _tokenizer.nextToken()
}

fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }.toMutableList().toLongArray()

@JvmField
val _writer = PrintWriter(OUTPUT, false)

inline fun output(block: PrintWriter.() -> Unit) {
    _writer.apply(block).flush()
}

fun printArr(arr: IntArray, start: Int, end: Int) {
    for (i in start..end) {
        print("${arr[i]} ")
    }
    println()
}

fun printArr(arr: LongArray, start: Int, end: Int) {
    for (i in start..end) {
        print("${arr[i]} ")
    }
    println()
}

fun main() {
    val (a, b, c) = readInts(3)
    if (a == b) println("YES")
    else if (a < c && b > 0) if (b == 1) println("YES") else println(if ((b - a) % c == 0) "YES" else "NO")
    else if (a > c && b < 0) if (b == -1) println("NO") else println(if ((b + a) % c == 0) "YES" else "NO")
    else println("NO")
    //TODO("KYS")
}