#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 15;
int p[N], cnt[N], dp[N];
int find(int v) { return (p[v] < 0) ? v : (p[v] = find(p[v])); }
void combine(int u, int v) {
  u = find(u);
  v = find(v);
  if (u == v) return;
  if (p[u] > p[v]) swap(u, v);
  p[u] += p[v];
  p[v] = u;
}
inline bool islucky(int n) {
  while (n) {
    if (n % 10 != 4 && n % 10 != 7) return false;
    n /= 10;
  }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(32);
  int n, m;
  cin >> n >> m;
  memset(p, -1, sizeof(p));
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    combine(u, v);
  }
  memset(cnt, 0, sizeof(cnt));
  memset(dp, 0x3f, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    if (i == find(i)) cnt[-p[find(i)]]++;
  }
  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int grp = 1, val = i; grp <= cnt[i]; grp <<= 1, val <<= 1) {
      for (int k = n - val; k >= 0; k--) {
        dp[k + val] = min(dp[k + val], dp[k] + grp);
      }
      cnt[i] -= grp;
    }
    if (cnt[i] > 0) {
      int val = i * cnt[i];
      for (int k = n - val; k >= 0; k--) {
        dp[k + val] = min(dp[k + val], dp[k] + cnt[i]);
      }
    }
  }
  int ans = dp[N - 1];
  for (int k = 1; k <= n; k++) {
    if (islucky(k)) ans = min(ans, dp[k] - 1);
  }
  if (ans <= n)
    cout << ans << '\n';
  else
    cout << -1 << '\n';
  return 0;
}
