#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g(1001), gr(1001), gu(1001);
vector<bool> used(1001);
vector<int> order, component;
void dfs1(int x) {
  used[x] = true;
  for (int i = 0; i < g[x].size(); i++) {
    if (!used[g[x][i]]) {
      dfs1(g[x][i]);
    }
  }
  order.push_back(x);
}
void dfs2(int x) {
  used[x] = true;
  component.push_back(x);
  for (auto y : gr[x]) {
    if (!used[y]) dfs2(y);
  }
}
void dfs(int x) {
  used[x] = true;
  for (auto y : gu[x]) {
    if (!used[y]) dfs(y);
  }
}
int main() {
  int n, m, a, b;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    g[a].push_back(b);
    gr[b].push_back(a);
    gu[b].push_back(a);
    gu[a].push_back(b);
  }
  for (int i = 1; i <= n; i++) {
    if (!used[i]) dfs1(i);
  }
  used.assign(n + 1, false);
  for (int i = order.size() - 1; i >= 0; i--) {
    int q = order[i];
    if (!used[q]) {
      component.clear();
      dfs2(q);
      if (component.size() > 1) return cout << "no", 0;
    }
  }
  used.assign(n + 1, false);
  dfs(1);
  for (int i = 1; i <= n; i++)
    if (!used[i]) return cout << "no", 0;
  cout << "yes";
}
