#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double, long long int>& firstElof,
                 const pair<double, long long int>& secondElof) {
  return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double, long long int>& firstElof,
                       const pair<double, long long int>& secondElof) {
  return firstElof.second < secondElof.second;
}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
struct edge {
  long long int from, to, cost;
};
long long int gcd(long long int a, long long int b) {
  if (a % b == 0)
    return (b);
  else
    return (gcd(b, a % b));
}
long long int n, m;
vector<vector<edge> > graph;
long long int cost[105][105];
bool used[105][105];
void warshall_floyd() {
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) {
      for (long long int k = 0; k < n; k++) {
        if (cost[i][j] > cost[i][k] + cost[k][j]) {
          cost[i][j] = cost[i][k] + cost[k][j];
        }
      }
    }
  }
}
vector<edge> dist;
int main() {
  long long int n, m;
  cin >> n >> m;
  graph = vector<vector<edge> >(n);
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) {
      if (i == j) {
        cost[i][j] = 0;
      } else {
        cost[i][j] = INF;
      }
    }
  }
  for (long long int i = 0; i < m; i++) {
    long long int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    cost[a][b] = c;
    cost[b][a] = c;
    edge e;
    e.from = a;
    e.to = b;
    e.cost = c;
    dist.push_back(e);
    e.from = b;
    e.to = a;
    e.cost = c;
    dist.push_back(e);
  }
  warshall_floyd();
  long long int ans = 0;
  for (long long int i = 0; i < dist.size(); i++) {
    bool flag = false;
    for (long long int j = 0; j < n; j++) {
      for (long long int k = 0; k < n; k++) {
        if (cost[j][dist[i].from] + dist[i].cost + cost[dist[i].to][j] ==
            cost[j][k]) {
          flag = true;
        }
      }
    }
    if (!flag) {
      ans++;
    }
  }
  cout << ans / 2 << endl;
  return 0;
}
