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