from collections import * N, M = map(int, input().split()) G = [[] for _ in range(N)] I = [t:=0]*N for _ in range(M): a, b = map(int, input().split()) G[a] += [b]; I[b] += 1 Q = deque(i for i in range(N) if I[i]<1) while Q: u = Q.popleft(); t += 1 if Q: print('NO'); exit() for v in G[u]: I[v] -= 1 if I[v]<1: Q.append(v) print('YNEOS'[t