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