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