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