#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

//頂点fromkら頂点へのtoへのコストcostの辺
struct edge { int from, to, cost;};

const int MAX_V = 100;
const int MAX_E = 10000;
const int INF = 9999;

edge es[MAX_E];

int prev[MAX_V];
int d[MAX_V];   //最短距離
 int V, E;       //Vは頂点数、Eは辺の数
int used[MAX_V][MAX_V];

//s番目の頂点から各頂点への最短距離を求める
void shortest_path(int s) {
  for(int i = 0; i < V; i++) d[i] = INF;
  fill(prev, prev + V, -1);
  d[s] = 0;
  while (true) {
    bool update = false;
    for(int i = 0; i < E; i++) {
      edge e = es[i];
      if (d[e.from] != INF &&  d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        update = true;
        prev[e.to] = prev[e.from];
      }
    }
    if(!update) break;
  }
}

vector<int> get_path(int t) {
  vector<int> path;
  for(; t != -1 ; t = prev[t]) path.push_back(t);
  reverse(path.begin(), path.end());
  return path;
}

int main() {
  int ans = 0;
  cin >> V >> E;

  for(int i = 0; i < E; i++) {
    cin >> es[i].to >> es[i].from >> es[i].cost;
  }

  for(int i = 0; i < V; i++) {
    shortest_path(i);
    for(int j = 1; j < V; j++) {
      vector<int> path = get_path(j);
      for(int k = 0; k < path.size()-1; k++) {
        used[path[k]][path[k+1]] = 1;
      }
    }
  }

  for(int i = 0; i < E; i++) {
    if(!used[es[i].to][es[i].from]) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}
