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