#include <bits/stdc++.h>
using namespace std;
int m, n, ans = 100000, mat[4000][4000];
vector<int> v[4000];
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    v[--a].push_back(--b);
    v[b].push_back(a);
    mat[a][b] = true;
    mat[b][a] = true;
  }
  for (int i = 0; i < n; i++) {
    if (v[i].size() > 1) {
      for (int j = 0; j < v[i].size(); j++) {
        for (int k = 0; k < v[i].size(); k++) {
          int a = v[i].size(), b = v[v[i][k]].size(), c = v[v[i][j]].size();
          if (mat[v[i][k]][v[i][j]] == true && j != k)
            ans = min(ans, a + b + c - 6);
        }
      }
    }
  }
  if (ans == 100000)
    cout << -1;
  else
    cout << ans;
  return 0;
}
