using System; using System.Collections.Generic; using System.Linq; public class Program{ public static void Main(){ var n = int.Parse(Console.ReadLine()); var a = new int[n]; var b = new int[n]; var c = new Queue(); for(var i=0;i m=='1'); b[i] = -1; } c.Enqueue(0); b[0] = 1; while(c.Count>0){ var k = c.Dequeue(); if(k+a[k]0&&b[k-a[k]]==-1){ c.Enqueue(k-a[k]); b[k-a[k]] = b[k] + 1; } } Console.WriteLine(b[n-1]); } }