#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vin = vector<int>;
using vll = vector<ll>;
using vst = vector<string>;
using P = pair<int, int>;
const int inf = 1e9 + 7;
const ll INF = 9e18;
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline void Yes(T condition) {
  if (condition)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
template <class T>
inline void YES(T condition) {
  if (condition)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int pass[110][110];
int main() {
  cout << fixed << setprecision(10);
  int n, m;
  cin >> n >> m;
  vector<vector<P>> rd(m);
  int a, b, c;
  for (int i = 0; i < (m); ++i) {
    cin >> a >> b >> c;
    a--;
    b--;
    rd[a].push_back(make_pair(b, c));
    rd[b].push_back(make_pair(a, c));
    pass[a][b]++;
    pass[b][a]++;
  }
  for (int i = 0; i < (n); ++i) {
    vin dist(n, inf);
    priority_queue<int, vin, greater<int>> pq;
    pq.push(i);
    dist[i] = 0;
    while (!pq.empty()) {
      int now = pq.top();
      pq.pop();
      for (auto v : rd[now]) {
        int next = v.first;
        if (chmin(dist[next], dist[now] + v.second)) {
          pq.push(next);
          pass[now][next]--;
          pass[next][now]--;
          if (now == 1 && next == 2) cout << 100 << endl;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (n); ++j) {
      if (pass[i][j] == 1) ans++;
    }
  cout << ans << endl;
}
