#include <bits/stdc++.h>
using namespace std;
map<long long, set<long long> > mp;
long long mn = INT_MAX;
void addedge(long long u, long long v, bool bidir = true) {
  mp[u].insert(v);
  if (bidir) mp[v].insert(u);
}
void solve() {
  for (auto i : mp) {
    for (auto j : mp[i.first]) {
      for (auto k : mp[j]) {
        if (mp[k].find(i.first) != mp[k].end()) {
          long long len = mp[i.first].size() + mp[j].size() + mp[k].size();
          mn = min(mn, len - 6);
        }
      }
    }
  }
}
signed main() {
  long long n, m;
  cin >> n >> m;
  long long a, b;
  while (m--) {
    cin >> a >> b;
    addedge(a, b);
  }
  solve();
  if (mn == INT_MAX)
    cout << -1;
  else
    cout << mn;
}
