#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const long long LINF = INF * (long long)INF;
const int MAX = 4 * 1000 + 47;
int G[MAX][MAX];
int DEG[MAX];
pair<int, int> E[MAX];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = (0); i < (m); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    E[i] = make_pair(a, b);
    G[a][b] = G[b][a] = 1;
    DEG[a]++;
    DEG[b]++;
  }
  int ans = INF;
  for (int i = (0); i < (m); i++) {
    for (int j = (0); j < (n); j++) {
      int a = E[i].first;
      int b = E[i].second;
      if (G[a][j] && G[b][j]) {
        ans = min(ans, DEG[a] + DEG[b] + DEG[j]);
      }
    }
  }
  if (ans == INF) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans - 6 << endl;
}
