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