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