A 3-way switch has 3 wires:
- Common = Hot (if it is the first switch) or Switched Hot (if it is the last switch)
- Travelers = 2 wires that travel between the switches
Standard US cables are black/white (2 wire) or black/red/white (3 wire). White is almost always neutral (there are exceptions that don't apply here). Your white wires are connected to together with a wire nut, so they are definitely neutral - nothing else would make any sense. Which means you have two possibilities:
- 2-wire cable = incoming hot & neutral. Black hot = common wire on switch. Neutral white connected to white in 3-wire cable
- 3-wire cable = two travelers (black and red) connected to switch and neutral (white) going to second switch box (but not to the switch itself)
- 3-wire cable = two travelers (black and red) connected to switch and neutral (white) coming from first switch box (but not from the switch itself)
- 2-wire cable = switched hot & neutral going to fixture. Switched hot black = common wire on switch. Neutral white connected to the other white.
In general there can be another possibility with white retasked as a hot wire. But that can't be the case here because you have 2 cables, not 3, and the whites are together.
Now back to the original question: Which wire is hot? That depends on the box. One of these is "first" = gets hot power from the panel and the other is "second"
= sends switched hot to the fixture. Power must be coming from the black wire of a 2-wire cable into one of the boxes. If you don't know which one is first:
- Turn off the breaker
- Disconnect the black wire in each box that is paired with a white wire and not also paired with a red wire. That wire will be hot in only one box. Make sure it is safe (ideally, capped and separated as much as possible from other wires).
- Turn on the breaker
- Use a non-contact tester to see which wire is hot
Assuming you only get one hot wire when testing, you have your answer. If you get more than one then you will need a multimeter to figure it out, or there may be other problems.
Once everything is done, the Harper method of labeling wires is:
- Put yellow tape on the travelers (which should be the black and red of the 3-wire cable)
- Put red tape on the switched hot (which will be the black wire of a 2-wire cable that is not always hot)
and that way you will know which wire is which the next time you open the boxes. Which will result in the following (thank you, as usual, @Harper):