#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double pi = acos(-1.0);
const double eps = 1e-9;
vector<int> a[100100];
int cp, n, m, u, v, mp[100100], used[100100], dp[100100], pd[100100];
vector<int> tv, tu;
bool pretty(int x) {
  while (x) {
    if ((x % 10) != 4 && (x % 10) != 7) return 0;
    x /= 10;
  }
  return 1;
}
void dfs(int v) {
  used[v] = 1;
  cp++;
  for (int i = 0; i < a[v].size(); i++) {
    int to = a[v][i];
    if (!used[to]) dfs(to);
  }
}
int main() {
  scanf("%d%d\n", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    a[u].push_back(v);
    a[v].push_back(u);
  }
  for (int i = 1; i <= n; i++)
    if (!used[i]) {
      cp = 0;
      dfs(i);
      mp[cp]++;
    }
  dp[0] = 1;
  for (int num = 1; num <= 77777; num++) {
    if (mp[num] == 0) continue;
    int x = mp[num], j = 0;
    while (x) {
      if ((1 << j) > x) {
        break;
      }
      x -= (1 << j);
      tv.push_back((1 << j) * num);
      tu.push_back((1 << j));
      j++;
    }
    if (x > 0) {
      tv.push_back(x * num);
      tu.push_back(x);
    }
  }
  for (int i = 0; i < tv.size(); i++)
    for (int j = 77777 - tv[i]; j >= 0; j--)
      if (dp[j]) {
        if (dp[j + tv[i]]) {
          pd[j + tv[i]] = min(pd[j + tv[i]], pd[j] + tu[i]);
        } else {
          dp[j + tv[i]] = 1;
          pd[j + tv[i]] = pd[j] + tu[i];
        }
      }
  int ma = (1 << 30);
  for (int i = 1; i <= 77777; i++) {
    if (!pretty(i) || !dp[i]) continue;
    if (pd[i] < ma) {
      ma = pd[i];
    }
  }
  if (ma == (1 << 30))
    cout << -1;
  else
    cout << ma - 1;
  return 0;
}
