#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000;
const int INF = 1e9;
int n, m, d[MAX][MAX];
vector<int> A, B, C;
void warshall_floyd() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
  }
}
int check() {
  int res = 0;
  bool shortest;
  for (int i = 0; i < m; i++) {
    shortest = false;
    for (int j = 0; j < n; j++) {
      if (d[j][A[i]] + C[i] == d[j][B[i]]) shortest = true;
    }
    if (shortest) res += 1;
  }
  return res;
}
int main() {
  int a, b, c, ans;
  scanf("%d", &n);
  scanf("%d", &m);
  fill((int*)d, (int*)(d + n), 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      if (i != j) d[i][j] = INF;
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
    A.push_back(a);
    B.push_back(b);
    C.push_back(c);
  }
  warshall_floyd();
  ans = m - check();
  cout << ans << endl;
  return 0;
}
