#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> v[4005];
int main() {
  while (cin >> n >> m) {
    for (int i = 0; i <= n; i++) v[i].clear();
    for (int i = 0; i < m; i++) {
      int x, y;
      cin >> x >> y;
      v[x].push_back(y);
      v[y].push_back(x);
    }
    int ans = -1;
    int mi = 1000000007;
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j < v[i].size(); j++) {
        for (int k = 0; k < v[v[i][j]].size(); k++) {
          for (int u = 0; u < v[v[v[i][j]][k]].size(); u++) {
            if (v[v[v[i][j]][k]][u] == i) {
              int tmp =
                  v[i].size() + v[v[i][j]].size() + v[v[v[i][j]][k]].size() - 6;
              mi = min(mi, tmp);
              ans = mi;
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
}
