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