Here's another way to do it, that I think is useful if you don't recognize/have knowledge of specific option spreads/techniques. This might help you on exams or other problems, although recognizing the different option plays is probably easier.
First you start from the left of the payoff graph, and split the graph into segments, just like how the payoff function itself is split into segments: So there's:
- a horizontal segment of value $3$ (slope $0$) until $S_T = 30$
- a segment of slope $-1$ from $30 \leq S_T \leq 35$
- a horizontal segment of value $-2$ (slope $0$) for $S_T >35$.
So you know that 'no matter what' you have $3 \text{USD}$ at maturity, until something happens at $S_T = 30$, so we just make a portfolio that gives us just that for now. That'd be a long zero coupon bond that pays $3 \text{USD}$ at time $T$, so it's present value in the portfolio is just $3e^{-r(T-t)}$. So the payoff so far that we have constructed is just a horizontal line for all $S_T$.
From there, we know that something occurs to make the slope become from $0$ to $-1$ and that this happens at $S_T = 30$. So we know we need to add to our portfolio a payoff that has slope $-1$ beginning at $S_T = 30$ and value $0$ for $S_T < 30$. If you visualize the type of payoff this is, it's just a call payoff for strike $30$ flipped across the x-axis, so it's a short call position of strike $30$. So now we have a portfolio, $3e^{-r(T-t)} - C(S_t, 30, T)$, and this fulfills the first two segments of the graph since the payoff is $3 + \min(30 - S_T,0)$, which is $3$ below $S_T = 30$ and $33 - S_T$ above $30$.
For the final segment, we know that 'something occurs' at $S_T = 35$ to make the slope $0$ again. This must be something of slope $1$ (since a slope of $1$ and $-1$ will lead to $0$ slope) beginning at $S_T = 35$. So this is just the payoff of a long call position. So we have the final portfolio of $3e^{-r(T-t)} - C(S_t, 30, T) + C(S_t,35,T)$, which has the payoff $3 + \min(30 - S_T,0) + \max(S_T - 35,0)$.
Just to check each case:
\begin{align*}
f(S_T)=\begin{cases}
3 + \min(30 - S_T,0) + \max(S_T - 35,0) = 3 + 0 + 0 = 3 & \text{if }S_T\leq 30, \\
3 + \min(30 - S_T,0) + \max(S_T - 35,0) = 3 + (30 - S_T) + 0 = 33- S_T & \text{if }30<S_T<35, \\
3 + \min(30 - S_T,0) + \max(S_T - 35,0) = 3 + (30 - S_T) + (S_T - 35) = -2 & \text{if } S_T\geq35.
\end{cases}
\end{align*}
I know @KeSchn already answered but hope this helps since this is how I usually do these. Of course, you can do this multiple ways but this gets to a correct answer relatively quickly.
Edit: Gordon's answer is definitely the way to go if you're comfortable with indicator functions. It does everything the graphical methods do without requiring any visualizing etc