Might also want this to just be `s += input[i]` -- since `LGLSXP`s are just `int`s under the hood (restricted to the values 0 and 1) that would be marginally more efficient.