#include <bits/stdc++.h>
using namespace std;
int adj[4500][4500];
int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> mp;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    adj[x][y] = 1;
    adj[y][x] = 1;
    mp[x]++;
    mp[y]++;
  }
  int mini = 10000000;
  bool c = false;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (adj[i][j]) {
        for (int k = j + 1; k <= n; k++)
          if (adj[i][k] && adj[j][k]) {
            mini = min(mini, mp[i] + mp[j] + mp[k] - 6);
            c = true;
          }
      }
    }
  }
  if (c)
    cout << mini << endl;
  else
    cout << "-1" << endl;
  return 0;
}
