#include <bits/stdc++.h>
int path[4000][4000];
int fox[4000];
int fox_v[4000];
int wolf[4000 * 2];
int wolf_v[4000 * 2];
int stumpnum;
int pathnum;
void fox_dijkstra();
void wolf_dijkstra();
int main(int argc, char const *argv[]) {
  int first, second, lenght;
  int count = 0;
  scanf("%d %d", &stumpnum, &pathnum);
  for (int i = 0; i < 4000; ++i) {
    for (int j = 0; j < 4000; ++j) {
      path[i][j] = 1000000000;
    }
    fox[i] = 1000000000;
    wolf[i * 2] = 1000000000;
    wolf[i * 2 + 1] = 1000000000;
  }
  while (pathnum--) {
    scanf("%d %d %d", &first, &second, &lenght);
    path[first - 1][second - 1] = lenght * 2;
    path[second - 1][first - 1] = lenght * 2;
  }
  fox_dijkstra();
  wolf_dijkstra();
  for (int i = 0; i < stumpnum; ++i) {
    if (fox[i] < wolf[i * 2] && fox[i] < wolf[i * 2 + 1]) {
      count++;
    }
  }
  printf("%d\n", count);
  return 0;
}
int fox_smallest_i();
void fox_dijkstra() {
  int index = 0;
  for (int i = 0; i < stumpnum; ++i) {
    fox[i] = path[index][i];
  }
  fox_v[index] = 1;
  for (int i = 0; i < stumpnum - 2; ++i) {
    index = fox_smallest_i();
    for (int j = 1; j < stumpnum; ++j) {
      if (!fox_v[j] && fox[index] + path[index][j] < fox[j]) {
        fox[j] = fox[index] + path[index][j];
      }
    }
  }
}
int fox_smallest_i() {
  int index = 0;
  int min = 1000000000;
  for (int i = 0; i < stumpnum; ++i) {
    if (!fox_v[i] && fox[i] < min) {
      index = i;
      min = fox[i];
    }
  }
  fox_v[index] = 1;
  return index;
}
int wolf_smallest_i();
void wolf_dijkstra() {
  int index = 0;
  for (int i = 1; i < stumpnum; ++i) {
    wolf[i * 2] =
        (path[index][i] != 1000000000 ? path[index][i] / 2 : 1000000000);
  }
  for (int i = 0; i < stumpnum * 2 - 2; ++i) {
    index = wolf_smallest_i();
    for (int j = 0; j < stumpnum; ++j) {
      if (index % 2) {
        if (path[index / 2][j] != 1000000000 && !wolf_v[j * 2] &&
            wolf[index] + path[index / 2][j] / 2 < wolf[j * 2]) {
          wolf[j * 2] = wolf[index] + path[index / 2][j] / 2;
        }
      } else {
        if (path[index / 2][j] != 1000000000 && !wolf_v[j * 2 + 1] &&
            wolf[index] + path[index / 2][j] * 2 < wolf[j * 2 + 1]) {
          wolf[j * 2 + 1] = wolf[index] + path[index / 2][j] * 2;
        }
      }
    }
  }
}
int wolf_smallest_i() {
  int index = 0;
  int min = 1000000000;
  for (int i = 0; i < stumpnum * 2; ++i) {
    if (!wolf_v[i] && wolf[i] < min) {
      index = i;
      min = wolf[i];
    }
  }
  wolf_v[index] = 1;
  return index;
}
