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