Help to get the best solution approach

Favorite braces are like {}, {{}}, {{{}}}
If s and t are favorite then s+t is favorite like {}{}
We can’t call a braces are favorite if }{, {}}{,

We can do one operation at a time to make them favorite.

  1. Either select any braces from the string and move it to start of the string
  2. Select any braces and move to the end of the string.

Assumption is there should be equal no. Of open and close braces.

Given an input string of braces. It is asked to find the minimum no. of operation required to make it favorite.

Example:
Input:
{}
Output
0
Input2:
}{
Output2:
1