#include <bits/stdc++.h>
using namespace std;
bool g[4005][4005];
int deg[4005], n, m;
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    g[a][b] = g[b][a] = 1;
    deg[a]++;
    deg[b]++;
  }
  int res = 1e6;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      if (g[i][j])
        for (int k = j + 1; k <= n; k++)
          if (g[i][k] & g[j][k]) res = min(res, deg[i] + deg[j] + deg[k]);
  if (res == 1e6)
    cout << -1;
  else
    cout << res - 6;
}
