#include <bits/stdc++.h>
using namespace std;
int n, m;
int g[105][105];
int d[105];
int vis[105];
void dijkstra(int s) {
  fill(d, d + n + 1, INT_MAX);
  d[s] = 0;
  while (true) {
    int u = -1, cost = INT_MAX;
    for (int i = 1; i <= n; i++) {
      if (!vis[i] && d[i] < cost) {
        cost = d[i];
        u = i;
      }
    }
    if (u == -1) break;
    vis[u] = true;
    for (int i = 1; i <= n; i++) {
      d[i] = min(d[i], d[u] + g[u][i]);
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      g[i][j] = INT_MAX;
    }
  }
  for (int i = 1; i <= m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    g[a][b] = c;
    g[b][a] = c;
  }
  dijkstra(1);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (d[i] == INT_MAX) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
