#include <bits/stdc++.h>
using namespace std;
template <typename T>
void debug(const T& elem, const char* msg){};
template <typename T>
void debug_arr(const T& arr, const char* msg){};
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (C == 0) {
    if (A == B) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  } else if (C > 0) {
    if (A == B) {
      cout << "YES" << endl;
    } else if (B - A > 0) {
      cout << ((B - A) % C == 0 ? "YES" : "NO") << endl;
    } else {
      cout << "NO" << endl;
    }
  } else {
    if (A == B) {
      cout << "YES" << endl;
    } else if (B - A < 0) {
      cout << ((A - B) % (-C) == 0 ? "YES" : "NO") << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}
