#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
void dance() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
void file() {
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
}
bool solve(pair<int, string> &a, pair<int, string> &b) {
  if (a.first > b.first)
    return 1;
  else if (a.first == b.first) {
    return a.second < b.second;
  }
  return 0;
}
long long MOD = 1000000007;
bool adj[4001][4001];
int rec[4001];
int main() {
  dance();
  int n, m, a, b, mn = INT_MAX;
  cin >> n >> m;
  while (m--) {
    cin >> a >> b;
    adj[a][b] = adj[b][a] = true;
    rec[a]++;
    rec[b]++;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (adj[i][j])
        for (int k = 1; k <= n; k++)
          if (adj[k][i] && adj[k][j]) mn = min(mn, rec[i] + rec[j] + rec[k]);
  cout << ((mn == INT_MAX) ? -1 : mn - 6) << endl;
}
