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