#include using namespace std; int main(){ int n,m;cin>>n>>m; if(m==1){ int a,b,c;cin>>a>>b>>c; cout << c << endl; }else{ int re = 0; for(int i = 0; m > i; i++){ int a,b,c;cin>>a>>b>>c; re += c; } cout << re << endl; } }