#include <bits/stdc++.h>
using namespace std;
class Node {
 public:
  int data;
  int state;
  int state1;
  list<Node*> near;
};
void mark(Node* node, int st) {
  if (node->state == 0) {
    node->state = st;
  } else {
    return;
  }
  for (list<Node*>::iterator it = node->near.begin(); it != node->near.end();
       ++it) {
    mark(*it, st);
  }
}
bool is_cycle(Node* node, int st, int st1) {
  bool result = false;
  if (node->state == st) {
    if (node->state1 == 0) {
      node->state1 = st1;
      for (list<Node*>::iterator it = node->near.begin();
           it != node->near.end(); ++it) {
        result = result || is_cycle(*it, st, st1 + 1);
      }
    } else {
      if (abs(node->state1 - st1) > 2) {
        return true;
      }
    }
  }
  return result;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<Node*> a(n + 1);
  for (int i = 1; i <= n; i++) {
    a[i] = new Node();
    a[i]->data = i;
    a[i]->state = 0;
    a[i]->state1 = 0;
  }
  int a1, a2;
  for (int i = 0; i < m; i++) {
    cin >> a1 >> a2;
    a[a1]->near.push_back(a[a2]);
    a[a2]->near.push_back(a[a1]);
  }
  int count = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i]->state == 0) {
      mark(a[i], count + 1);
      count++;
    }
  }
  int cur = 1;
  int cycle = 0;
  int k = 1;
  while (k <= n) {
    if (a[k]->state == cur) {
      if (is_cycle(a[k], cur, 1)) {
        cycle++;
      }
      cur++;
    }
    k++;
  }
  cout << count - cycle;
  return 0;
}
