import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val s = sc.next()
    var ans = 0L

    for (i <- 1 to 100) {
      ans += f((2019 * i).toString, s, 0)
    }
    println(ans)
  }

  @scala.annotation.tailrec
  def f(m: String, s: String, i: Int): Int = {
    if (s.length < m.length) i
    else if (s.startsWith(m)) f(m, s.tail, i + 1)
    else f(m, s.tail, i)
  }
}
