From what I read, the brown and black wires aren’t used on Nest. Apparently they are for outdoor temperature sensors that nest doesn’t need. But I’ve never done this job. For what it is worth, here is what YouTube says

You have a 3rd gen Nest Learning thermostat. There is a YouTube video posted by nest here:
https://www.youtube.com/watch?v=dHKD-9uI24IHere is a guy explaining the wiring:
https://www.youtube.com/watch?v=CCNIko3iZIEThe only thing to consider is if the red wire goes to the Rc or the Rh terminal. That depends on the type of system you have. Based on your old thermostat it looks like your red should go to Rh
Here is some info on whether the R wire goes to RC or RH:
The placement of the R wire, also known as the power or 24-volt wire, depends on the specific HVAC system and thermostat setup. In most cases, the R wire is connected to either the RC (cooling) terminal or the RH (heating) terminal on the thermostat. However, there are factors to consider when determining the appropriate connection:
1. Single transformer system: If your HVAC system has a single transformer that provides power for both heating and cooling, the R wire is typically connected to the RH terminal. In this setup, the RH terminal powers both the heating and cooling functions of the thermostat.
2. Separate transformer system: Some HVAC systems have separate transformers for heating and cooling. In this case, the R wire should be connected to both the RH and RC terminals. The RC terminal is for cooling-specific functions, while the RH terminal is for heating-specific functions.
3. Heat-only systems: If you have a heat-only system, such as a furnace or boiler without central air conditioning, the R wire is connected to the RH terminal.
4. Heat pump systems: Heat pump systems can have different configurations depending on the specific model and setup. In most cases, the R wire is connected to the RC terminal, and a separate wire (typically labeled "C" for common) is connected to the RH terminal to provide a common 24-volt connection. However, it's important to consult the manufacturer's documentation or seek professional guidance to determine the correct wiring for your heat pump system.
It's important to note that the R wire is only one component of the thermostat wiring. Other wires, such as W, Y, G, and C, are responsible for controlling specific functions of the HVAC system. It's recommended to refer to the thermostat manufacturer's instructions or consult a qualified HVAC technician for proper wiring guidance based on your specific system and thermostat model.
To ensure safe and accurate wiring, following the manufacturer's instructions, consulting professional guidance, or seeking assistance from an HVAC technician when working with thermostat wiring is always recommended.