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