package main import ( "bufio" "fmt" "os" "strconv" "strings" ) func main() { input := bufio.NewScanner(os.Stdin) var output int var digits []int var target int for input.Scan() { line := input.Text() digits = []int{} values := strings.Split(line, " ") length := len(values) for index, v := range values { d, _ := strconv.Atoi(v) if index == length-1 { target = d break } digits = append(digits, d) } output = search(digits, target) fmt.Println(output) } } func search(nums []int, target int) int { var count int for _, v := range nums { if v == target { count++ } } return count }