#include <bits/stdc++.h>
using namespace std;
const signed int MAX = 4000 + 5;
const signed int INF = 1e9;
bool grid[MAX][MAX];
vector<pair<signed int, signed int> > edge;
signed int deg[MAX];
signed int main() {
  signed int n;
  signed int m;
  scanf("%d %d", &n, &m);
  signed int first, second;
  for (signed int i = 0; i < (m); ++i)
    scanf("%d %d", &first, &second), deg[first]++, deg[second]++,
        grid[first][second] = 1, grid[second][first] = 1,
        edge.push_back(pair<signed int, signed int>(first, second));
  signed int limit = (signed int)((edge).size());
  signed int ans = INF;
  for (signed int i = 0; i < (limit - 1); ++i) {
    for (signed int j = (i + 1); j <= (limit - 1); ++j) {
      pair<signed int, signed int> e1 = edge[i];
      pair<signed int, signed int> e2 = edge[j];
      if (e1.first == e2.first && e1.second != e2.second &&
          grid[e1.second][e2.second])
        ans = min(ans, deg[e1.first] + deg[e1.second] + deg[e2.second]);
      else if (e1.first == e2.second && e1.second != e2.first &&
               grid[e1.second][e2.first])
        ans = min(ans, deg[e1.first] + deg[e1.second] + deg[e2.first]);
      else if (e1.second == e2.first && e1.first != e2.second &&
               grid[e1.first][e2.second])
        ans = min(ans, deg[e1.second] + deg[e1.first] + deg[e2.second]);
      else if (e1.second == e2.second && e1.first != e2.first &&
               grid[e1.first][e2.first])
        ans = min(ans, deg[e1.second] + deg[e1.first] + deg[e2.first]);
    }
  }
  if (ans == INF) ans = 5;
  printf("%d\n", ans - 6);
  return 0;
}
