#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  bool conn[n + 5][n + 5];
  int kol[n + 5];
  for (int i = 0; i <= n; i++) kol[i] = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++) conn[i][j] = false;
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    conn[a][b] = conn[b][a] = true;
    kol[a]++;
    kol[b]++;
  }
  int ans = 1000005;
  for (int i = 1; i <= n - 2; i++)
    for (int j = i + 1; j <= n - 1; j++)
      if (conn[i][j])
        for (int k = j + 1; k <= n; k++)
          if (conn[i][k] && conn[j][k])
            ans = min(ans, kol[i] + kol[j] + kol[k]);
  if (ans != 1000005)
    printf("%d", ans - 6);
  else
    printf("-1");
}
