#include <bits/stdc++.h>
using namespace std;
vector<int> v[12345];
bool match[4001][4001] = {0};
int main() {
  int n, m, x, y;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
    match[x][y] = 1;
    match[y][x] = 1;
  }
  int ans = INT_MAX;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < (int)v[i].size(); j++) {
      for (int k = 0; k < (int)v[i].size(); k++) {
        if (match[v[i][k]][v[i][j]] == 1) {
          ans = min(ans, (int)v[i].size() + (int)v[v[i][j]].size() +
                             (int)v[v[i][k]].size() - 6);
        }
      }
    }
  }
  printf("%d\n", ans == INT_MAX ? -1 : ans);
  return 0;
}
