#include <bits/stdc++.h>
using namespace std;
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 aprev[MAX_V];
int d[MAX_V];
int V, E;
int used[MAX_V][MAX_V];
void shortest_path(int s) {
  for (int i = 0; i < V; i++) d[i] = INF;
  for (int i = 0; i < V; i++) aprev[i] = -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;
        aprev[e.to] = aprev[e.from];
      }
    }
    if (!update) break;
  }
}
vector<int> get_path(int t) {
  vector<int> path;
  for (; t != -1; t = aprev[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;
}
