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