#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> degree(n + 1, 0);
  vector<vector<bool> > t(n + 1, vector<bool>(n + 1));
  while (m--) {
    int a, b;
    cin >> a >> b;
    t[a][b] = t[b][a] = true;
    degree[a]++;
    degree[b]++;
  }
  int result = INT_MAX;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (t[i][j]) {
        for (int k = j + 1; k <= n; k++) {
          if (t[i][k] && t[j][k]) {
            result = min(result, degree[i] + degree[j] + degree[k]);
          }
        }
      }
    }
  }
  if (result == INT_MAX)
    cout << -1;
  else
    cout << result - 6;
  return 0;
}
