Problem:
Score : 100 points

Problem Statement

Snuke has N integers: 1,2,\ldots,N.
He will choose K of them and give those to Takahashi.

How many ways are there to choose K consecutive integers?

Constraints

All values in input are integers.

1 \leq K \leq N \leq 50

Input

Input is given from Standard Input in the following format:

N K

Output

Print the answer.

Sample Input 1

3 2

Sample Output 1

2

There are two ways to choose two consecutive integers: (1,2) and (2,3).

Sample Input 2

13 3

Sample Output 2

11

Solution in Go (1.6) (judge verdict: Runtime Error)

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func main() {
	var counter int
	N := oneInt()
	var sentences []string
	for index := 0; index < N; index++ {
		s := oneStr()
		counter += strings.Count(s, "AB")
		sentences = append(sentences, s)
	}
	sumOfA := countLastA(sentences)
	sumOfB := countFirstB(sentences)
	sumOfAB := countAB(sentences)
	if sumOfAB == 1 && sumOfA == 1 && sumOfB == 1 {
		fmt.Printf("%v", counter)
		return
	}

	if sumOfB >= sumOfA {
		fmt.Printf("%v", sumOfA+counter)
	} else {
		fmt.Printf("%v", sumOfB+counter)
	}

}

func countLastA(sentence []string) int {
	counter := 0
	for _, s := range sentence {
		if s[len(s)-1] == 'A' {
			counter++
		}
	}
	return counter
}

func countFirstB(sentence []string) int {
	counter := 0
	for _, s := range sentence {
		if s[0] == 'B' {
			counter++
		}
	}
	return counter
}

func countAB(sentence []string) int {
	counter := 0
	for _, s := range sentence {
		if s[0] == 'B' && s[len(s)-1] == 'A' {
			counter++
		}
	}
	return counter
}