#include <bits/stdc++.h>

using namespace std;


int graph[101][101];
int dist[101][101];
int prev[101][101];
int V;
int cnt[101][101], mark[101][101];

void floydWarshall ()
{
    int i, j, k;
 
    for (i = 0; i < V; i++)
        for (j = 0; j < V; j++) {
        	if(!graph[i][j])	continue;
            dist[i][j] = graph[i][j];
            mark[i][j] = 1;
            cnt[i][j]++;
            prev[i][j] = i;
        }
 
    for (k = 0; k < V; k++)
    {
        // Pick all vertices as source one by one
        for (i = 0; i < V; i++)
        {
            for (j = 0; j < V; j++)
            {
            	if(!graph[i][k] && !graph[k][j])	continue;
                if (dist[i][k] + dist[k][j] < dist[i][j]) {
                    dist[i][j] = dist[i][k] + dist[k][j];
                    if(prev[i][j] != -1) {
		                if(cnt[prev[i][j]][j] == 1)	mark[prev[i][j]][j] = 0;
	                    cnt[prev[i][j]][j]--;
	                }
                    mark[k][j] = 1;
                    cnt[k][j]++;
                    prev[i][j] = k;

                }
            }
        }
    }
}

set<pair<int, int> > s;

// void f() {
// 	for(int i = 0; i < V; ++i) {
// 		for(int j = 0; j < V; ++j) {
// 			if(i == j)	continue;

// 			int curr = pre[i][j];
// 			int curr2 = j;

// 			while(curr2 != curr) {
// 				if(curr > curr2)	swap(curr, curr2);
// 				s.insert(make_pair(curr, curr2));
// 				curr2 = curr;
// 				curr = pre[i][curr2];
// 			}
// 		}
// 	}
// }

int main(void) {

	
	int n, m;
	cin>>n>>m;
	memset(graph, 0, sizeof(graph));
	memset(cnt, 0, sizeof(cnt));
	memset(mark, 0, sizeof(mark));
	memset(prev, -1, sizeof(prev));

	for(int i = 0; i < m; ++i) {
		int a, b, c;
		cin>>a>>b>>c;
		
		--a, --b;
		graph[a][b] = c;
		graph[b][a] = c;
	}
	V = n;
	floydWarshall();
	

	int cnt = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = i+1; j < n; ++j) {
			if(mark[i][j])	cnt++;
			//cout<<mark[i][j];
		}
		//cout<<endl;
	}

	cout<<(m-cnt);

	return 0;
}

