#include <bits/stdc++.h>
using namespace std;
bool graph[4003][4003] = {{false}};
int d[100030] = {0};
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    graph[a][b] = true;
    graph[b][a] = true;
    d[a]++;
    d[b]++;
  }
  int in = 1e7, ans = 1e7;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (graph[i][j]) {
        for (int k = j + 1; k <= n; k++) {
          if (graph[k][i] && graph[k][j]) {
            ans = min(ans, d[i] + d[j] + d[k] - 6);
          }
        }
      }
    }
  }
  if (ans == 1e7) {
    cout << -1;
  } else {
    cout << ans;
  }
}
