#include <bits/stdc++.h>
using namespace std;
int a[4001], c[4001][4001], ans;
map<pair<int, int>, int> m1;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, i, j;
  scanf("%d %d", &n, &m);
  int b[m][2];
  ans = 100000;
  for (i = 0; i < m; i++) {
    scanf("%d %d", &b[i][0], &b[i][1]);
    a[b[i][0]]++;
    a[b[i][1]]++;
    c[min(b[i][0], b[i][1])][max(b[i][0], b[i][1])] = 1;
  }
  for (i = 0; i < m; i++) {
    for (j = 1; j <= n; j++) {
      if (j != b[i][0] && j != b[i][1]) {
        if (c[min(b[i][0], j)][max(b[i][0], j)] == 1 &&
            c[min(b[i][1], j)][max(b[i][1], j)] == 1)
          ans = min(ans, a[b[i][0]] + a[b[i][1]] + a[j] - 6);
      }
    }
  }
  if (ans == 100000) ans = -1;
  printf("%d", ans);
  return 0;
}
