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