#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5, inf = 1e9 + 69, delta = 1e9 + 7, max_sum = 10000 + 5,
          SQRT = 333;
int lucky[62] = {7,     4,     77,    74,    47,    44,    777,   774,   747,
                 744,   477,   474,   447,   444,   7777,  7774,  7747,  7744,
                 7477,  7474,  7447,  7444,  4777,  4774,  4747,  4744,  4477,
                 4474,  4447,  4444,  77777, 77774, 77747, 77744, 77477, 77474,
                 77447, 77444, 74777, 74774, 74747, 74744, 74477, 74474, 74447,
                 74444, 47777, 47774, 47747, 47744, 47477, 47474, 47447, 47444,
                 44777, 44774, 44747, 44744, 44477, 44474, 44447, 44444};
int main() {
  vector<int> adj[maxn];
  bool mark[maxn];
  int dp[maxn], c[maxn];
  int n, m;
  int u, v, sz;
  int x, cnt, pos;
  int i, j, r;
  pair<int, int> pi;
  deque<pair<int, int> > deq;
  ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  memset(dp, inf, sizeof dp);
  dp[0] = -1;
  scanf("%d%d", &n, &m);
  while (m--) {
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  queue<int> q;
  for (int i = 1; i <= n; i++)
    if (!mark[i]) {
      v = i;
      sz = 0;
      q.push(v);
      mark[v] = true;
      while (q.size()) {
        v = q.front();
        q.pop();
        sz++;
        for (auto u : adj[v])
          if (!mark[u]) {
            mark[u] = true;
            q.push(u);
          }
      }
      c[sz]++;
    }
  for (j = 1; j <= n; j++)
    if (c[j]) {
      x = j;
      cnt = c[j];
      for (r = 0; r < x; r++) {
        deq.clear();
        for (i = 0; i * x + r <= n; i++) {
          pos = i * x + r;
          while (!deq.empty() and (pos - deq.front().second) / x > cnt)
            deq.pop_front();
          while (!deq.empty() and dp[pos] - i <= deq.back().first)
            deq.pop_back();
          deq.push_back(make_pair(dp[pos] - i, pos));
          pi = deq.front();
          dp[pos] = pi.first + (pos - r) / x;
        }
      }
    }
  int ans = inf;
  for (int i = 0; i < 62; i++) ans = min(ans, dp[lucky[i]]);
  if (ans >= inf)
    cout << -1;
  else
    cout << max(0, ans);
  return 0;
}
