#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  if (!c) {
    cout << (a == b ? "YES" : "NO") << "\n";
  } else if (a == b) {
    cout << "YES\n";
  } else if (a >= 0 && b >= 0 && c >= 0) {
    a > b              ? cout << "NO\n"
    : (b - a) % c == 0 ? cout << "YES\n"
                       : cout << "NO\n";
  } else if (a < 0 && b >= 0 && c >= 0) {
    cout << (abs(b - a) % c == 0 ? "YES\n" : "NO\n");
  } else if (a >= 0 && b < 0 && c < 0) {
    int tmp = abs(a - b);
    cout << ((tmp) % (-c) == 0 ? "YES\n" : "NO\n");
  } else if (a >= 0 && b >= 0 && c < 0) {
    a < b                 ? cout << "NO\n"
    : (a - b) % (-c) == 0 ? cout << "YES\n"
                          : cout << "NO\n";
  } else if (a < 0 && b < 0 && c >= 0) {
    a < b ? (a - b) % c == 0 ? cout << "YES\n" : cout << "NO\n"
          : cout << "NO\n";
  } else if (a < 0 && b < 0 && c < 0) {
    a *= -1, b *= -1, c *= -1;
    a > b              ? cout << "NO\n"
    : (b - a) % c == 0 ? cout << "YES\n"
                       : cout << "NO\n";
  } else
    cout << "NO\n";
}
