#include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;
using VVI = vector<VI>;
using P = pair<int, int>;
using LL = long long;
int N;
vector<int> edge;
int pos(int x, int y) { return N * x + y; }
void warshallFloyd(vector<int>& d) {
  for (int i = (0); i < (N); ++i) {
    for (int j = (0); j < (N); ++j) {
      d[pos(i, j)] = edge[pos(i, j)];
    }
  }
  for (int k = (0); k < (N); ++k) {
    for (int i = (0); i < (N); ++i) {
      for (int j = (0); j < (N); ++j) {
        if (d[pos(i, j)] > d[pos(i, k)] + d[pos(k, j)])
          d[pos(i, j)] = d[pos(i, k)] + d[pos(k, j)];
      }
    }
  }
}
int main() {
  cin >> N;
  int M;
  cin >> M;
  ;
  vector<int> d(N * N);
  edge.resize(N * N);
  fill((edge).begin(), (edge).end(), 1000000);
  for (int i = (0); i < (M); ++i) {
    int a;
    cin >> a;
    ;
    int b;
    cin >> b;
    ;
    int c;
    cin >> c;
    ;
    edge[pos(a - 1, b - 1)] = edge[pos(b - 1, a - 1)] = c;
  }
  warshallFloyd(d);
  vector<bool> included(N * N, false);
  for (int i = (0); i < (N); ++i) {
    for (int j = (0); j < (N); ++j) {
      if (i == j) continue;
      if (edge[pos(i, j)] == d[pos(i, j)]) included[pos(i, j)] = true;
      for (int k = (0); k < (N); ++k) {
        if (d[pos(i, j)] == d[pos(i, k)] + d[pos(k, j)]) {
          included[pos(i, k)] = included[pos(k, j)] = true;
        }
      }
    }
  }
  int count = 0;
  for (int i = (0); i < (N); ++i) {
    for (int j = (i + 1); j < (N); ++j) {
      if (edge[pos(i, j)] != 1000000 && !included[pos(i, j)]) {
        ++count;
      }
    }
  }
  cout << count << endl;
  return 0;
}
