#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
bool adj[4005][4005];
int edges[4005];
int main() {
  int n, m, res = INF;
  cin >> n >> m;
  while (m--) {
    int a, b;
    cin >> a >> b;
    adj[a][b] = adj[b][a] = 1;
    edges[a]++;
    edges[b]++;
  }
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      if (adj[i][j] == 1) {
        for (int k = j + 1; k <= n; k++)
          if (adj[j][k] == 1 && adj[k][i] == 1)
            res = min(res, edges[i] + edges[j] + edges[k] - 6);
      }
    }
  if (res == INF)
    puts("-1");
  else
    cout << res << endl;
  return 0;
}
