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