#include <bits/stdc++.h>
using namespace std;
const long long LINF = ~(((long long)0x1) << 63) / 2;
const int INF = 0X3F3F3F3F;
int c[110000];
int num[111000];
int dp[210000];
vector<int> edge[100100];
int ok[100100];
map<int, int> mp;
int re;
void dfs(int s) {
  if (ok[s]) return;
  ok[s] = 1;
  re++;
  for (int i = 0; i < edge[s].size(); i++) dfs(edge[s][i]);
}
bool isok(int k) {
  while (k) {
    int s = k % 10;
    if (s != 4 && s != 7) return false;
    k /= 10;
  }
  return true;
}
int main() {
  int n, m, i, j, k, f, t, v, p;
  int cas = 1;
  while (scanf("%d%d", &n, &m) != EOF) {
    for (i = 0; i <= n; i++) {
      edge[i].clear();
      ok[i] = 0;
      num[i] = 0;
    }
    mp.clear();
    while (m--) {
      scanf("%d%d", &f, &t);
      edge[f].push_back(t);
      edge[t].push_back(f);
    }
    int sum = 0;
    for (i = 1; i <= 200000; i++) dp[i] = INF;
    for (i = 1; i <= n; i++) {
      re = 0;
      dfs(i);
      if (re != 0) {
        if (mp.count(re) == 0) {
          mp[re] = ++sum;
          c[sum] = re;
        }
        num[mp[re]]++;
      }
    }
    if (cas == 34) {
      cout << sum << endl;
    }
    cas++;
    for (i = 1; i <= sum; i++) {
      for (j = 1; num[i] > 0; j *= 2) {
        k = j;
        if (j > num[i]) k = num[i];
        int d = k;
        k = k * c[i];
        for (v = 2 * n; v >= k; v--)
          if (dp[v] > dp[v - k] + d) dp[v] = dp[v - k] + d;
        num[i] -= d;
      }
    }
    int ans = INF;
    for (i = 1; i <= 2 * n; i++)
      if (dp[i] < ans && isok(i)) ans = dp[i];
    if (ans == INF)
      ans = -1;
    else
      ans--;
    cout << ans << endl;
  }
  return 0;
}
