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