#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
const int maxx = 4005;
bool t[maxx][maxx];
int degree[maxx];
int main() {
  int a, b, n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    t[a][b] = t[b][a] = true;
    degree[a]++;
    degree[b]++;
  }
  int result = inf;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (t[i][j]) {
        for (int k = j + 1; k <= n; k++) {
          if (t[i][k] && t[j][k]) {
            result = min(result, degree[i] + degree[j] + degree[k]);
          }
        }
      }
    }
  }
  if (result == inf)
    cout << -1 << "\n";
  else
    cout << result - 6 << "\n";
  return 0;
}
