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