For clarity, I label the switches and output slots as follows:
Switches are labeled from left to right, top to bottom as 1-7. Slots are labeled left to right as A-F.
If we keep dropping coins down slot 1, eventually a coin will come out slot A. At that point we know switch 1 is facing out without coin and switch 3 is facing in without coin. This takes at most 5 drops.
We repeat with slot 4 until a coin comes out slot F. At that point we know switch 2 is facing out without coin and switch 5 is facing in without coin. This also takes at most 5 coins. Total: $\leq 10$.
If we dropped fewer than four coins down slot 4, we drop four more coins down slot 4. This yields another coin out slot F and leaves switches 2 and 5 in place. It also ensures at least two coins fell on the right side of switch 4, guaranteeing that switch now points to the right. Total: $\leq 12$.
We next drop a coin down slot 2. If a coin came out slot C, but not B, we know switch 6 is now empty and facing in. If nothing came out, we know switch 6 is now full, facing in. If two coins came out, we know switch 6 is now empty, but don't know which direction it's facing.
We next drop a coin down slot 3. Likewise, if a coin came out D, we know switch 7 is now empty facing in. If nothing came out, it's full facing in. If two coins came out, it's empty, facing one direction or other.
If we don't know the direction of switch 6, we drop a coin down slot 1, then another down slot 2. (This leaves switch 3 with a coin on it). We now know switch 6 is facing in. If a coin came out slot C, switch 6 is now empty; if not, it is now full. Likewise, if we don't know the direction of switch 7, we drop a coin down slot 4 then another down slot 3. Total: $\leq 18$.
We now know all switches are facing in and we know which way switch 4 is facing. Switches 3, 5, 6, and 7 might be holding coins, depending on above details.
We then follow an algorithm for adding coins when we know what's going on. We first ensure switches 6 and 7 have coins, then 3, 4, and 5, then 1 and 2. The worst case would be if switches 3, 5, and 6 now have coins, but 7 doesn't, in which case, it would take 10 more coins to finish.
Total: $\leq 28$ coins.
Is this plan optimal? No. In the interest of writing a simple algorithm, I ignored a lot of other information we could have gathered. Keeping track of all that information could allow for shortcuts requiring fewer coins.