#include <bits/stdc++.h>
using namespace std;
int known[4009][4009], degree[4009];
vector<pair<int, int> > vt;
int main() {
  int n, m;
  long long int sum = 10000000000000000;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int a, b;
    cin >> a >> b;
    known[a][b] = 1;
    known[b][a] = 1;
    degree[a]++;
    degree[b]++;
    vt.push_back(make_pair(a, b));
  }
  int i, j;
  for (i = 0; i < m; ++i) {
    for (j = 1; j <= n; ++j) {
      if (known[vt[i].first][j] && known[vt[i].second][j]) {
        long long int temp =
            degree[vt[i].first] + degree[vt[i].second] + degree[j] - 6;
        if (temp < sum) sum = temp;
      }
    }
  }
  if (sum == 10000000000000000)
    cout << "-1";
  else
    cout << sum;
}
