#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <string>
#include <cstring>
using namespace std;

int m1[222222], m2[222222], deg[22222], asf[22222], c[222222], res[22222];
int main() {
    FILE *ff = fopen("asfalt.in", "r");
    FILE *gg = fopen("asfalt.out", "w");
    int n, m;
    fscanf(ff, "%d%d", &n, &m);
    for (int i = 0; i < 22222; i++) deg[i] = asf[i] = 0;
    for (int i = 1; i <= m; i++) {
        fscanf(ff, "%d%d%d", &m1[i], &m2[i], &c[i]);
        deg[m1[i]]++;
        deg[m2[i]]++;
        asf[m1[i]] += c[i];
        asf[m2[i]] += c[i];
    }
    int sol = 0;
    for (int i = 1; i <= n; i++) if (deg[i] == asf[i]) {
        sol++;
        res[sol] = i;
    }
    fprintf(gg, "%d\n", sol);
    for (int i = 1; i <= sol; i++) fprintf(gg, "%d ", res[i]);
}
