#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<pair<int, int> > v;
int mat[4002][4002];
int deg[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int i, j;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    v.push_back(make_pair(x, y));
    deg[x]++;
    deg[y]++;
    mat[x][y] = 1;
    mat[y][x] = 1;
  }
  int ans = INT_MAX;
  for (i = 0; i < m; i++) {
    for (j = 1; j <= n; j++) {
      if (j != v[i].first && j != v[i].second) {
        if (mat[j][v[i].first] && mat[j][v[i].second]) {
          ans = min(ans, deg[v[i].first] + deg[v[i].second] + deg[j] - 6);
        }
      }
    }
  }
  if (ans == INT_MAX) ans = -1;
  cout << ans;
}
