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