#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
const size_t N = 4001;
const int inf = 1 << 30;
int fame[N];
int know[N][N];
int main() {
  std::ios_base::sync_with_stdio(false);
  memset(fame, 0, sizeof fame);
  for (size_t i = 0; i < N; ++i) memset(know[i], 0, sizeof know[i]);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    know[a][b] = know[b][a] = 1;
    ++fame[a];
    ++fame[b];
  }
  int out = inf;
  for (int a = 0; a <= n; ++a)
    for (int b = a + 1; b <= n; ++b)
      if (know[a][b]) {
        for (int c = b + 1; c <= n; ++c)
          if (know[a][c] && know[b][c])
            out = std::min(out, fame[a] + fame[b] + fame[c] - 6);
      }
  cout << (out == inf ? -1 : out);
  return 0;
}
