input = puts().to_i

n = (input / 100).floor
d = input % 100

list = [0, 1, 2, 3, 4, 5]

found = false

cnt = 0
while(cnt < 6 ^ n)
  sum = 0
  indicies = cnt.to_s(6).split('')
  indicies.each_with_index do |index|
    sum += list[index]
  end
  found = true if d == sum
  break if found
  cnt += 1
end

puts found ? 1 : 0