#include <bits/stdc++.h>
using namespace std;
int N;
vector<pair<pair<int, int>, int> > edges[100005];
int main() {
  ios_base::sync_with_stdio(0);
  int n, m, k;
  while (cin >> n >> m >> k) {
    for (int i = 0; i < 100005; i++) edges[i].clear();
    N = n;
    for (int i = 0; i < m; i++) {
      int u, v, x;
      cin >> u >> v >> x;
      u--;
      v--;
      edges[u].push_back(make_pair(make_pair(v, x), 1));
      edges[v].push_back(make_pair(make_pair(u, x), 1));
    }
    for (int i = 0; i < k; i++) {
      int s, y;
      cin >> s >> y;
      s--;
      edges[0].push_back(make_pair(make_pair(s, y), 0));
    }
    bool visited[N];
    memset((visited), 0, sizeof((visited)));
    priority_queue<pair<long long, pair<int, int> > > pq;
    pq.push(make_pair(-1, make_pair(0, 0)));
    int res = 0;
    while (!pq.empty()) {
      pair<int, pair<long long, int> > p = pq.top();
      pq.pop();
      long long dist = -p.first;
      int edge_type = p.second.first;
      int node = p.second.second;
      if (visited[node]) {
        if (edge_type == 0) res++;
        continue;
      }
      visited[node] = 1;
      for (int e = 0; e < edges[node].size(); e++) {
        pair<pair<int, int>, int> p = edges[node][e];
        int neigh = p.first.first;
        int d = p.first.second;
        int type = p.second;
        if (visited[neigh]) {
          if (type == 0) res++;
          continue;
        }
        pq.push(make_pair(-(dist + d), make_pair(type, neigh)));
      }
    }
    cout << res << endl;
  }
}
