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