#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T x) {
  return x * x;
}
long double pi = 3.1415926535897932384626433832795;
const int N = 5e5 + 10, lg = 20;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  if (c == 0) {
    if (a != b)
      cout << "NO";
    else
      cout << "YES";
    return 0;
  }
  if (a == b || ((a > b && c < 0) && (a - b) % (-c) == 0) ||
      ((a < b && c > 0) && (b - a) % c == 0))
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
