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