#include <bits/stdc++.h>
using namespace std;
static const int MAX = 100;
static const long long INF = 10000000;
long long d[MAX][MAX];
int N, M;
struct Data {
  int u, v;
  long long c;
  Data() {}
  Data(int u, int v, long long c) : u(u), v(v), c(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 main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j)
        d[i][j] = 0;
      else
        d[i][j] = INF;
    }
  }
  Data data[M];
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    data[i] = Data(a, b, c);
    d[a][b] = c;
    d[b][a] = c;
  }
  int cnt = 0;
  warshall_floyd();
  for (int i = 0; i < M; i++) {
    int a = data[i].u;
    int b = data[i].v;
    bool flag = true;
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        long long d1 = d[j][a] + data[i].c + d[b][k];
        long long d2 = d[j][k];
        if (d1 == d2) {
          flag = false;
          goto loop;
        }
      }
    }
  loop:
    if (flag) cnt++;
  }
  cout << cnt << "\n";
  return 0;
}
