import java.util.*;

public class AlternativePath {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        if (!sc.hasNextInt()) return;

        int n = sc.nextInt();
        int m = sc.nextInt();

        List<List<Integer>> adj = new ArrayList<>(n + 1);
        for (int i = 0; i <= n; i++) {
            adj.add(new ArrayList<>());
        }
        for (int i = 0; i < m; i++) {
            int u = sc.nextInt();
            int v = sc.nextInt();

            adj.get(u).add(v);
            adj.get(v).add(u);
        }
        System.out.println(maxBeautifulVertices(n, adj));
    }

    public static int maxBeautifulVertices(int n, List<List<Integer>> adj) {
        int[] color = new int[n + 1];
        Arrays.fill(color, -1);
        
        int totalBeautiful = 0;

        for (int i = 1; i <= n; i++) {
            if (color[i] == -1) {
                int[] counts = new int[2]; 
                boolean isBipartite = true; 

                Queue<Integer> queue = new LinkedList<>();
                queue.add(i);
                color[i] = 0; 
                counts[0]++;

                while (!queue.isEmpty()) {
                    int u = queue.poll();

                    for (int v : adj.get(u)) {
                        if (color[v] == -1) {
                            color[v] = 1 - color[u];
                            counts[color[v]]++;
                            queue.add(v);
                        } else if (color[v] == color[u]) {
                            isBipartite = false;
                        }
                    }
                }

                if (isBipartite) {
                    totalBeautiful += Math.max(counts[0], counts[1]);
                }
            }
        }

        return totalBeautiful;
    }
}