#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  long a, b, c;
  cin >> a >> b >> c;
  if (a == b) {
    cout << "YES" << endl;
    return 0;
  }
  if (c == 0) {
    cout << "NO" << endl;
    return 0;
  }
  if (c == 1) {
    if (b > a) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
    return 0;
  }
  if (c == -1) {
    if (b < a) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
    return 0;
  }
  if (c < 0) {
    c *= -1;
    b *= -1;
    a *= -1;
  }
  if (b < a) {
    cout << "NO" << endl;
    return 0;
  }
  long ar = a % c;
  long br = b % c;
  if (ar < 0) {
    ar += c;
  }
  if (br < 0) {
    br += c;
  }
  if (ar == br) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
