import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;

public class D {
    static LinkedList<Integer>[] E;
    static int[] M;
    static boolean[] visited;
    static int n;
    static int center;

    public static boolean match(int x) {
        if (visited[x])
            return false;
        visited[x] = true;
        for (int y : E[x])
            if (y != center && (M[y] == -1 || match(M[y]))) {
                M[y] = x;
                return true;
            }
        return false;
    }

    public static int maxMatch() {
        int res = 0;
        Arrays.fill(M, -1);
        for (int i = 0; i < n; i++) {
            Arrays.fill(visited, false);
            if (i != center && match(i))
                res++;
        }
        return res;
    }

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        n = in.readInt();
        int m = in.readInt();
        E = new LinkedList[n];
        M = new int[n];
        boolean[][] C = new boolean[n][n];
        visited = new boolean[n];
        for (int i = 0; i < n; i++)
            E[i] = new LinkedList<Integer>();
        for (int i = 0; i < m; i++) {
            int x = in.readInt() - 1;
            int y = in.readInt() - 1;
            C[x][y] = true;
            E[x].add(y);
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int res = 0;
            int all = 0;
            for (int j = 0; j < n; j++)
                if (j != i) {
                    all += E[j].size();
                    if (!C[i][j])
                        res++;
                    if (!C[j][i])
                        res++;
                    else
                        all--;
                }
            if (!C[i][i])
                res++;
            center = i;
            int match = maxMatch();
            res += (all - match) + (n - match - 1);
            min = Math.min(min,... Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?