Similar setting of the [previous](https://www.codewars.com/kata/progressive-spiral-number-position/), this time you are called to identify in which "branch" of the spiral a given number will end up.
Considering a square of numbers disposed as the 25 items in [the previous kata](https://www.codewars.com/kata/progressive-spiral-number-position/), the branch are numbered as it follows:
```
17 16 15 14 13    1 1 1 1 0
18 05 04 03 12    2 1 1 0 0
19 06 01 02 11 => 2 2 0 0 0
20 07 08 09 10    2 2 3 3 0
21 22 23 24 25    2 3 3 3 3
```
Meaning that, for example, numbers in the `10-13` range will be in branch `0`, numbers in the range `14-17` are inside branch `1`, all those nice numbers in the `18-21` can call branch `2` their house and finally the `21-25` team all falls under the `3` branch.
Your function must return the number of the index of each number [`1` being a special case you might consider equivalent to being in the first branch, `0`], as per examples:
```python
branch(1) == 0 #kind of special case here
branch(5) == 1
branch(25) == 3
branch(30) == 0
branch(50) == 0
```
It might help A LOT to both solve the [previous kata](https://www.codewars.com/kata/progressive-spiral-number-position/) and to visualize the diagonals of the square. Be ready for big numbers and, as usual, inspired by [AoC](http://adventofcode.com/2017/day/3). Finally, when ready, go to compute [the distance](https://www.codewars.com/kata/progressive-spiral-number-distance/) of the series.
k, li = 1, [0]

for i in range(1, 1000000):
    li.append(k)
    k += 8 * i
    
def branch(n):
    a,b = next([i,li[i-1]+1] for i,j in enumerate(li) if j>=n)
    step = a*2-2
    for i in range(4):
        if b<=n<b+step : return i
        b += step
    return 0
k, li = 1, [0]

for i in range(1, 1000000):
    li.append(k)
    k += 8 * i
    
def branch(n):
    a,b = next([i,li[i-1]+1] for i,j in enumerate(li) if j>=n)
    step = a*2-2
    for i in range(4):
        if b<=n<b+step : return i
        b += step
    return 0