#include <bits/stdc++.h>
using namespace std;
const int mx = 4005;
bool t[mx][mx];
int d[mx], x[mx], y[mx];
int main() {
  int n, m, a, b;
  cin >> n >> m;
  for (int i = 0; i < m; i++)
    cin >> x[i] >> y[i], t[x[i]][y[i]] = t[y[i]][x[i]] = true, d[x[i]]++,
                         d[y[i]]++;
  int ans = 1e9;
  for (int i = 0; i < m; i++)
    for (int j = 1; j <= n; j++)
      if (t[x[i]][j] && t[j][y[i]]) ans = min(ans, d[x[i]] + d[j] + d[y[i]]);
  if (ans == 1e9)
    cout << "-1" << endl;
  else
    cout << ans - 6 << endl;
  return 0;
}
