#include <bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int u[N],v[N],w[N];
int s=0;
int main(){
	freopen("road.in","r",stdin);
	freopen("road.out","w",stdout);
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=m;i++){
		cin>>u[i]>>v[i]>>w[i];s+=w[i];
	}
	cout<<s;
	return 0;
}
