#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
long long int vis[200005] = {0};
vector<int> v[4005];
vector<set<long long int>> myset(200005);
vector<long long int> put;
long long int par[200005] = {0};
long long int sz[200005] = {0};
int a[4005][4005];
int main() {
  int n, m, y, x, i, ans = 99999;
  cin >> n >> m;
  while (m--) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
    a[x][y] = 1;
    a[y][x] = 1;
  }
  for (i = 1; i <= n; i++) {
    for (auto pp : v[i]) {
      for (auto kk : v[i]) {
        if (a[pp][kk] == 1) {
          y = v[pp].size() + v[kk].size() + v[i].size();
          ans = min(ans, y);
        }
      }
    }
  }
  if (ans == 99999)
    ans = -1;
  else
    ans -= 6;
  cout << ans;
  return 0;
}
