#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int a, b, c;
  cin >> a >> b >> c;
  if (c == 0) {
    if (a == b)
      puts("YES");
    else
      puts("NO");
    return 0;
  }
  if (((b - a) % c == 0 and b >= a and c >= 0) or
      (a - b) % c == 0 and b <= a and c <= 0)
    puts("YES");
  else
    puts("NO");
  return 0;
}
