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