#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long t = 1;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    vector<vector<long long>> graph(n + 1, vector<long long>(n + 1, 0));
    vector<long long> degree(n + 1, 0);
    for (long long i = 0; i < m; i++) {
      long long a, b;
      cin >> a >> b;
      graph[a][b] = 1;
      graph[b][a] = 1;
      degree[a]++;
      degree[b]++;
    }
    long long ans = INT_MAX;
    long long flag = 0;
    for (long long i = 1; i <= n; i++) {
      for (long long j = i + 1; j <= n; j++) {
        if (graph[i][j]) {
          for (long long k = j + 1; k <= n; k++) {
            if (graph[j][k] && graph[k][i]) {
              ans = min(ans, degree[i] + degree[j] + degree[k]);
              flag = 1;
            }
          }
        }
      }
    }
    if (flag == 0)
      cout << -1 << "\n";
    else
      cout << ans - 6 << "\n";
  }
  return 0;
}
