#include<iostream>
#include<vector>
using namespace std;
vector<vector<int>> graph;
vector<bool> vis;
void dfs_graph(int node,vector<bool>& vis,vector<vector<int>>& graph){
if(vis[node]) return;
vis[node] = true;
for(int neighbor : graph[node]){
if(!vis[neighbor])
dfs_graph(neighbor,vis,graph);
}
}
int main(){
int n,m;
cin >> n >> m;
graph.resize(n);
vis.resize(n,false);
for(int i = 0 ; i < n; i ++){
int x,y;
cin >> x >> y;
graph[x].push_back(y);
graph[y].push_back(x);
}
dfs_graph(1,vis,graph);
int ans = 0;
for(int i = 0; i < n; i ++){
for(int j : graph[i]){
if(!vis[j]) ans ++;
}
}
cout << ans + 1 << endl;
return 0;
}