  for(i = 0; i < q; i++){
    key = T[i];
    left = 0;
    right = n;
    
    while(left < right){
      mid = (left + right) / 2;
      
      if(key == S[mid]) count++;

      if(key > S[mid]) left = mid + 1;
      else if(key < S[mid]) right = mid;
    }
  }