#include <bits/stdc++.h>
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
using namespace std;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int d[100];
  fill(d, d + n, 999999999);
  vector<pair<int, int>> G[n];
  for (int i = 0; i < m; ++i) {
    int t1, t2, t3;
    scanf("%d %d %d", &t1, &t2, &t3);
    t1--;
    t2--;
    G[t1].push_back(make_pair(t3, t2));
  }
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      que;
  que.push(pair<int, int>(0, 0));
  int res = 0;
  d[0] = 0;
  while (!que.empty()) {
    int cost = que.top().first, v = que.top().second;
    que.pop();
    if (d[v] < cost) continue;
    for (int i = 0; i < G[v].size(); ++i) {
      pair<int, int> p = G[v][i];
      int next_cost = p.first, next_v = p.second;
      if (d[next_v] > d[v] + next_cost) {
        d[next_v] = d[v] + next_cost;
        que.push(pair<int, int>(d[next_v], next_v));
      } else if (d[next_v] < d[v] + next_cost) {
        res++;
      }
    }
  }
  printf("%d\n", res);
  return 0;
}
