#include <bits/stdc++.h>
using namespace std;
int n, mn, mx, mxl, m, x, y, b, root, k, type, ans;
int main() {
  cin >> x >> y >> n;
  if (x == y) {
    cout << "YES";
  } else if (n == 0) {
    cout << "NO";
  } else if (n > 0) {
    if (x > y) {
      cout << "NO";
    } else {
      y -= x;
      if (y % n == 0) {
        cout << "YES";
      } else {
        cout << "NO";
      }
    }
  } else if (n < 0) {
    if (x < y) {
      cout << "NO";
    } else {
      x = x - y;
      n = -n;
      if (x % n == 0) {
        cout << "YES";
      } else {
        cout << "NO";
      }
    }
  }
}
