#include <bits/stdc++.h>
using namespace std;
vector<long long> v[4005];
int main() {
  long long n, m, i, x = 0, y = 0, z = 0, t1, t2, minm = INT_MAX, j, c1, c2, c3,
                     k, x1 = 0, l;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> t1 >> t2;
    v[t1].push_back(t2);
    v[t2].push_back(t1);
  }
  for (i = 1; i <= n; i++) {
    x = i;
    if (v[i].size() == 0) continue;
    for (j = 0; j < v[i].size() - 1; j++) {
      y = v[i][j];
      if (y < x) continue;
      for (l = j + 1; l < v[i].size(); l++) {
        z = v[i][l];
        for (k = 0; k < v[y].size(); k++) {
          if (v[y][k] == z) {
            x1++;
            c1 = v[i].size() - 2;
            c2 = v[y].size() - 2;
            c3 = v[z].size() - 2;
            if (c1 + c2 + c3 < minm) minm = c1 + c2 + c3;
            break;
          }
        }
      }
    }
  }
  if (x1 > 0)
    cout << minm;
  else
    cout << -1;
  return 0;
}
