#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, t, p, l;
  int a, b, c;
  cin >> a >> b >> c;
  n = abs(a - b);
  if (c == 0) {
    if (a == b) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  } else if (a > b && c > 0) {
    cout << "NO" << endl;
    return 0;
  } else if (a < b && c < 0) {
    cout << "NO" << endl;
    return 0;
  } else if (n % c == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
