#include <bits/stdc++.h>
using namespace std;
const int maxn = 4005;
vector<int> v[maxn];
int vis[maxn][maxn];
int main(void) {
  int n, m, ans = maxn;
  memset(vis, 0, sizeof(vis));
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
    vis[x][y] = vis[y][x] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (!vis[i][j]) continue;
      for (int k = j + 1; k <= n; k++) {
        if (!vis[i][k] || !vis[k][j]) continue;
        int cur = 0;
        int len = v[i].size();
        for (int d = 0; d < len; d++) {
          if (v[i][d] != j && v[i][d] != k) cur++;
        }
        len = v[j].size();
        for (int d = 0; d < len; d++) {
          if (v[j][d] != i && v[j][d] != k) cur++;
        }
        len = v[k].size();
        for (int d = 0; d < len; d++) {
          if (v[k][d] != i && v[k][d] != j) cur++;
        }
        ans = min(ans, cur);
      }
    }
  }
  if (ans == maxn)
    printf("-1\n");
  else
    printf("%d\n", ans);
}
