#include <bits/stdc++.h>
using namespace std;
long long mo = 1000000007;
template <class T, class S>
void cmin(T &a, const S &b) {
  if (a > b) a = b;
}
template <class T, class S>
void cmax(T &a, const S &b) {
  if (a < b) a = b;
}
template <class A>
void PR(A a, long long n) {
  for (int i = 0; i < n; i++) {
    if (i) cout << ' ';
    cout << a[i];
  }
  cout << "\n";
}
long double PI = 3.14159265358979323846;
vector<vector<long long>> G(101);
vector<vector<long long>> dd(101, vector<long long>(101, 1e18));
vector<vector<long long>> d(101, vector<long long>(101, 1e18));
void warshall_floyd(int n) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++) d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}
int main() {
  long long N, M;
  cin >> N >> M;
  long long a, b, c;
  for (int i = 0; i < M; i++) {
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
  }
  for (int i = 0; i < N; i++) {
    d[i][i] = 0;
  }
  dd = d;
  warshall_floyd(N);
  long long cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        if (i == j || j == k || k == i) continue;
        if (d[i][k] == d[i][j] + dd[j][k]) {
          cnt++;
        }
      }
    }
  }
  cout << M - cnt << endl;
}
