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