#include <iostream>
#include <cstring>
#include <stdio.h>
using namespace std;

#define MaxN 20010

int n,m;

int d[MaxN];
int l[MaxN];
bool mark[MaxN];

int u,v,a;

int main()
{
    freopen("asfalt.in","r",stdin);
    freopen("asfalt.out","w",stdout);

    scanf("%d%d",&n,&m);
    for (int i = 0; i < m; ++i) {
        scanf("%d%d%d",&u,&v,&a);
        u--; v--;

        mark[u] = true;
        mark[v] = true;
        d[u] += a;
        d[v] += a;

        l[u]++;
        l[v]++;
    }

    int ret = 0;
    for (int i = 0; i < MaxN; ++i) {
        if ( mark[i] && d[i] == l[i] ) ret++;
    }
    printf("%d\n",ret);

    bool first = true;
    for (int i = 0; i < MaxN; ++i)
        if ( mark[i] && d[i] == l[i] ) {
            if ( first ) {
                printf("%d",i+1);
                first = false;
            }
            else {
                printf(" %d",i+1);
            }
        }
    printf("\n");

    return 0;
}
