#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, ans = -1, res = INT_MAX, i, j, x, y, minn = INT_MAX;
  cin >> n >> k;
  vector<int> v[n + 1];
  vector<pair<int, int> > adj;
  map<pair<int, int>, int> m;
  for (i = 0; i < k; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
    adj.push_back(make_pair(x, y));
    m[make_pair(x, y)] = 1;
    m[make_pair(y, x)] = 1;
  }
  for (i = 0; i < adj.size(); i++) {
    x = adj[i].first;
    y = adj[i].second;
    minn = min(v[x].size(), v[y].size());
    if (minn == v[x].size()) {
      for (j = 0; j < minn; j++) {
        if (m[{y, v[x][j]}] == 1) {
          ans = v[x].size() + v[y].size() + v[v[x][j]].size() - 6;
          res = min(res, ans);
        }
      }
    } else {
      for (j = 0; j < minn; j++) {
        if (m[{x, v[y][j]}] == 1) {
          ans = v[x].size() + v[y].size() + v[v[y][j]].size() - 6;
          res = min(res, ans);
        }
      }
    }
  }
  if (ans == -1)
    cout << ans << endl;
  else
    cout << res << endl;
  return 0;
}
