#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n);
  vector<int> b(n);
  map<pair<int, int>, bool> e;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    e[make_pair(x, y)] = 1;
    a[x].push_back(y);
    a[y].push_back(x);
    b[x]++;
    b[y]++;
  }
  int ans = INT_MAX;
  for (int i = 0; i < n; i++)
    for (int j : a[i])
      for (int k : a[i]) {
        if (j != k && e.find(make_pair(j, k)) != e.end())
          ans = min(ans, b[i] + b[j] + b[k]);
      }
  if (ans != INT_MAX)
    cout << ans - 6;
  else
    cout << -1;
}
