#include #define SP putchar(' ') #define EL putchar('\n') #define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout) using uint = unsigned; using ll = long long; using ull = unsigned long long; using pii = std::pair; const int N = 505; const int Mod = 998244353; void inc(int &a, int b) { (a += b) >= Mod ? a -= Mod : a; } void dec(int &a, int b) { (a -= b) < 0 ? a += Mod : a; } int pow(int a, int b, int ans = 1); int rank(); std::mt19937_64 rnd(std::random_device{}()); std::uniform_int_distribution D(0, Mod - 1); int mat[N][N]; int n, m; int main() { scanf("%d %d", &n, &m); for (int i = 1; i <= m; ++i) { int u, v, w; scanf("%d %d %d", &u, &v, &w); int x = D(rnd); inc(mat[u][v], x), inc(mat[v][w], x), inc(mat[w][u], x); dec(mat[v][u], x), dec(mat[w][v], x), dec(mat[u][w], x); } printf("%d\n", rank() / 2); return 0; } int rank() { int ans = 0; for (int i = 1; i <= n; ++i) { int now = 0; for (int j = ans + 1; j <= n; ++j) { if (mat[j][i]) now = j; } if (!now) continue; ++ans; if (now != ans) std::swap(mat[ans], mat[now]); int iv = pow(mat[ans][i], Mod - 2); for (int j = i; j <= n; ++j) mat[ans][j] = 1ll * mat[ans][j] * iv % Mod; for (int j = ans + 1; j <= n; ++j) { for (int k = n; k >= i; --k) mat[j][k] = (mat[j][k] + 1ll * (Mod - mat[j][i]) * mat[ans][k]) % Mod; } } return ans; } int pow(int a, int b, int ans) { while (b) { if (b & 1) ans = 1ll * ans * a % Mod; a = 1ll * a * a % Mod; b >>= 1; } return ans; }