#include <bits/stdc++.h>
using namespace std;
static long long llMAX = numeric_limits<long long>::max();
static int intMAX = numeric_limits<int>::max();
static long long llMIN = numeric_limits<long long>::min();
static int intMIN = numeric_limits<int>::min();
static long long d_5 = 100000;
static long long d9_7 = 1000000007;
static long long d_9 = 1000000000;
template <class T>
void Printvector(std::vector<T> a) {
  int size = a.size();
  for (long long i = 0; i < size; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
template <class T>
void Printvector(std::vector<std::vector<T>> a) {
  int size = a.size();
  for (long long i = 0; i < size; i++) {
    int size2 = a[i].size();
    for (long long j = 0; j < size2; j++) {
      cout << a[i][j] << " ";
    }
    cout << endl;
  }
  cout << endl;
}
long long digitpower(long long a, long long b) {
  if (b == 1) {
    return a;
  } else if (b == 0) {
    return 1;
  }
  if (b % 2 == 1) {
    long long tmp = digitpower(a, (b - 1) / 2);
    tmp %= d9_7;
    tmp *= tmp;
    tmp %= d9_7;
    tmp *= a;
    return (tmp) % d9_7;
  } else {
    long long tmp = digitpower(a, (b) / 2);
    tmp %= d9_7;
    tmp *= tmp;
    tmp %= d9_7;
    return (tmp) % d9_7;
  }
}
struct datas {
  int cost;
  int now;
  vector<int> past;
  deque<pair<int, int>> edges;
};
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> graph(n, vector<int>(n, intMAX / 100));
  vector<set<int>> nexts(n);
  vector<int> as(m), bs(m);
  for (long long i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    as[i] = a;
    bs[i] = b;
    graph[a][b] = c;
    graph[b][a] = c;
    nexts[a].insert(b);
    nexts[b].insert(a);
  }
  vector<vector<int>> washa = graph;
  for (long long k = 0; k < n; k++)
    for (long long i = 0; i < n; i++)
      for (long long j = 0; j < n; j++) {
        washa[i][j] = min(washa[i][j], washa[i][k] + washa[k][j]);
      }
  set<pair<int, int>> nums;
  int ans = 0;
  for (long long k = 0; k < m; k++) {
    for (long long i = 0; i < n; i++)
      for (long long j = 0; j < n; j++) {
        if (i == j) continue;
        if (washa[i][as[k]] + graph[as[k]][bs[k]] + washa[bs[k]][j] ==
            washa[i][j]) {
          ans++;
        }
      }
  }
  cout << m - ans / 2 << endl;
  return 0;
}
