function killKthBit($n, $k) {
  return $k > strlen(decbin($n)) ? $n : (substr(decbin($n), -$k, 1) == 0 ? $n : bindec(substr_replace(decbin($n), '0', -$k, 1))) ;
}