#include <bits/stdc++.h>
inline int Rand() { return (rand() << 16) | rand(); }
using namespace std;
const int N = 4001;
int n, m, x, y, ans, to, pos;
set<int> g[N];
set<int>::iterator it, it2;
bool was[N][N];
bool fl;
int main() {
  srand(time(NULL));
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &x, &y);
    g[x].insert(y);
    g[y].insert(x);
    was[x][y] = true;
    was[y][x] = true;
  }
  ans = 2000000000;
  for (int i = 1; i <= n; i++) {
    for (it = g[i].begin(); it != g[i].end(); it++) {
      for (it2 = g[i].begin(); it2 != g[i].end(); it2++) {
        if (it == it2) continue;
        if (was[*it][*it2])
          ans = min(ans, int(g[i].size() - 2 + g[*it].size() - 2 +
                             g[*it2].size() - 2));
      }
    }
  }
  printf("%d", ans == 2000000000 ? -1 : ans);
  return 0;
}
