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