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