#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j;
  cin >> n >> m;
  vector<vector<int>> adj(n + 1), mat(n + 1, vector<int>(n + 1, 0));
  for (i = 0; i < m; ++i) {
    int t1, t2;
    cin >> t1 >> t2;
    adj[t1].push_back(t2);
    mat[t1][t2] = 1;
    adj[t2].push_back(t1);
    mat[t2][t1] = 1;
  }
  int ans = INT_MAX, k;
  for (i = 1; i <= n; ++i) {
    for (j = 0; j < adj[i].size(); ++j) {
      for (k = 1; k <= n; ++k) {
        if (mat[k][i] == 1 && mat[k][adj[i][j]] == 1) {
          int tcnt = adj[k].size() + adj[i].size() + adj[adj[i][j]].size();
          ans = min(ans, tcnt - 6);
        }
      }
    }
  }
  ans == INT_MAX ? cout << -1 << "\n" : cout << ans << "\n";
  return 0;
}
