#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b, c, x, y, f = 0;
  cin >> a >> b >> c;
  if (c == 0 && b == a)
    f = 1;
  else if (c == 0 && a != b)
    f = 0;
  else {
    x = b - a;
    if ((x * c) < 0)
      f = 0;
    else if (x % c == 0) {
      y = x / c;
      if (y + 1 > 0) f = 1;
    }
  }
  if (f)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
