#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000;
int main() {
  int n, m, a[1001], b[1001], c[1001];
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> a[i] >> b[i] >> c[i];
  }
  bool k[1001] = {};
  bool h = false;
  int t[101];
  for (int i = 0; i <= n; ++i) t[i] = INF;
  t[1] = 0;
  while (1) {
    h = false;
    for (int i = 0; i < m; ++i) {
      if (t[a[i]] + c[i] < t[b[i]]) {
        k[i] = true;
        h = true;
        t[b[i]] = t[a[i]] + c[i];
      }
      if (t[a[i]] + c[i] == t[b[i]]) k[i] = true;
      if (t[b[i]] + c[i] < t[a[i]]) {
        k[i] = true;
        h = true;
        t[a[i]] = t[b[i]] + c[i];
      }
      if (t[b[i]] + c[i] == t[a[i]]) k[i] = true;
    }
    if (!h) break;
  }
  int r = 0;
  for (int i = 0; i < m; ++i) {
    if (!k[i]) ++r;
  }
  cout << r << endl;
  return 0;
}
