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