Bernardo chooses a four-digit positive integer and writes both its base-7 and base-8 representations on a blackboard. Later LeRoy sees the two numbers Bernardo has written. Treating the two numbers as base-10 integers, he adds them to obtain an integer . For example, if , Bernardo writes the numbers and , and LeRoy obtains the sum . Determine how many choices of are there such that the three rightmost digits of , in order, are the same as those of .