#include <bits/stdc++.h>
using namespace std;
vector<int> adj[4001];
bool adj_matrix[4001][4001];
void reset() {
  for (int i = 0; i < 4001; i++) {
    for (int j = 0; j < 4001; j++) {
      adj_matrix[i][j] = false;
    }
  }
}
bool magkakakilala(int a, int b, int c) {
  return adj_matrix[a][b] && adj_matrix[b][c] && adj_matrix[a][c];
}
int main() {
  reset();
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
    adj_matrix[a][b] = true;
    adj_matrix[b][a] = true;
  }
  int mincost = 99999999;
  for (int a = 1; a <= n; a++) {
    for (int i = 0; i < adj[a].size(); i++) {
      int b = adj[a][i];
      for (int j = i + 1; j < adj[a].size(); j++) {
        int c = adj[a][j];
        if (magkakakilala(a, b, c)) {
          int cost = adj[a].size() + adj[b].size() + adj[c].size() - 6;
          if (mincost > cost) mincost = cost;
        }
      }
    }
  }
  if (mincost == 99999999) mincost = -1;
  printf("%d\n", mincost);
}
