#05AB1E, 17 bytes
Lε35SÖ4*OygM}.¥sk
Try it online or verify all test cases.
Explanation:
L # Create a list in the range [1, (implicit) input]
# i.e. 15 → [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
ε # Map each value to:
35S # Push 35 as digit list: [3,5]
Ö # Check if the current value is divisible by these (1 if truthy; 0 if falsey)
4* # Multiply both by 4
O # And take the sum of that
# i.e. 2 → [0,0] → [0,0] → 0
# i.e. 9 → [1,0] → [4,0] → 4
# i.e. 10 → [0,1] → [0,4] → 4
# i.e. 15 → [1,1] → [4,4] → 8
yg # Push the current value again, and pop and push it's length
# i.e. 2 → 1
# i.e. 15 → 2
M # And then push the largest value on the stack
# i.e. 0 and 1 → 1
# i.e. 8 and 2 → 8
}.¥ # After the map: undelta the list (starting from 0)
# i.e. [1,1,4,1,4,4,1,1,4,4,2,4,2,2,8]
# → [0,1,2,6,7,11,15,16,17,21,25,27,31,33,35,43]
sk # Swap to get the (implicit) input, and get its 0-based index in the list
# i.e. 15 → 6
# (after which the result is output implicitly)