Okay, let's try to figure out this problem. So, Zach has three bags and some pencils. He needs to put the same number of pencils in each bag, and he wants to maximize the number of pencils in each bag. But we need to find out the maximum number of pencils he could have left over. Hmm.

First, I need to understand the problem correctly. Zach is distributing pencils into three bags. He wants each bag to have the same number of pencils, and he wants to put as many as possible. But we need to find the maximum remainder, which is the pencils left after dividing them equally into three bags. So, the remainder when the total number of pencils is divided by 3. But the question is asking for the greatest number of pencils he could have left over. Wait, but if he's putting the greatest number possible into each bag, then the remainder would be the leftover pencils after dividing by 3. So, the maximum possible remainder when dividing by 3 is 2, since the possible remainders are 0, 1, or 2. So, the answer might be 2. But let me make sure.

Wait, maybe I'm missing something. Let's think again. If Zach is trying to put the greatest number of pencils into each bag, while keeping the number the same in each, then the number of pencils per bag would be the largest possible integer such that total pencils is at least 3 times that number. But the remainder would be the leftover pencils. So, to maximize the remainder, we need the remainder to be as large as possible, which is 2. But is there a constraint on the total number of pencils? The problem says "a bunch of pencils," but doesn't specify a particular number. So, if the number of pencils can be any number, then the maximum remainder when divided by 3 is 2. Therefore, the greatest number of pencils he could have left over is 2. But let me check with an example.

Suppose there are 4 pencils. Divided by 3, that's 1 pencil per bag with 1 left over. Wait, remainder is 1. If there are 5 pencils, divided by 3 is 1 per bag, remainder 2. So, remainder 2. If there are 6 pencils, remainder 0. 7 pencils: 2 per bag, remainder 1. 8 pencils: 2 per bag, remainder 2. 9 pencils: 3 per bag, remainder 0. So, indeed, the maximum possible remainder is 2. Therefore, the answer is 2. But wait, the problem says "greatest number of pencils he could have left over." So, regardless of the total number of pencils, the maximum remainder is 2. Therefore, the answer is 2. But let me think again.

Alternatively, maybe the problem is asking for the maximum possible remainder given that he's placing the greatest number of pencils in each bag. Wait, maybe the problem is that he's trying to maximize the number of pencils per bag, but we need to find the maximum remainder possible. So, if the total number of pencils is N, then N = 3k + r, where r is 0, 1, or 2. The remainder r is the leftover pencils. So, the maximum possible r is 2. Therefore, regardless of how many pencils there are, the maximum remainder is 2. Therefore, the answer is 2. But let me check with different N.

For example, if N=4: 3*1 +1, remainder 1. If N=5: 3*1 +2, remainder 2. If N=7: 3*2 +1, remainder 1. If N=8: 3*2 +2, remainder 2. If N=10: 3*3 +1, remainder 1. So, yes, the maximum remainder is 2. Therefore, the answer is 2. But the problem says "the greatest number of pencils he could have left over." So, 2 is the maximum possible remainder. Therefore, the answer is 2. So, the final answer is \boxed{2}.
</think>