#include <bits/stdc++.h>
using namespace std;
long long cnt[100500], a[5005][5005];
long long ans = 0, i, j, ele, n, aa, bb, sm, m;
vector<pair<long long, long long> > v;
int main() {
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> aa >> bb;
    a[aa][bb] = 1;
    a[bb][aa] = 1;
    cnt[aa]++;
    cnt[bb]++;
    v.push_back(make_pair(aa, bb));
  }
  sm = 100000000;
  for (i = 0; i < m; i++) {
    for (j = i + 1; j < m; j++) {
      if (v[i].second == v[j].first && a[v[i].first][v[j].second] == 1) {
        sm = min(sm, cnt[v[i].first] + cnt[v[i].second] + cnt[v[j].second] - 6);
      } else if (v[i].second == v[j].second && a[v[i].first][v[j].first] == 1) {
        sm = min(sm, cnt[v[i].first] + cnt[v[i].second] + cnt[v[j].first] - 6);
      } else if (v[i].first == v[j].first && a[v[i].second][v[j].second] == 1) {
        sm = min(sm, cnt[v[i].first] + cnt[v[i].second] + cnt[v[j].second] - 6);
      } else if (v[i].first == v[j].second && a[v[i].second][v[j].first] == 1) {
        sm = min(sm, cnt[v[i].first] + cnt[v[i].second] + cnt[v[j].first] - 6);
      }
    }
  }
  if (sm == 100000000)
    cout << "-1";
  else
    cout << sm;
}
