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 Java8 (OpenJDK 1.8.0) (judge verdict: Runtime Error)


import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		int ans = 0;
		for(int i = 0; i < n; i++){
			s[i] = sc.next();
			if(s[i].equals(s[i].replace("AB", "0"))) {
			}else {
				ans += (s[i].length() - s[i].replace("AB", "0").length());
				}
			}
		int ca = 0;
		int cb = 0;
		boolean ja = false;
		boolean jb = false;
		int cc = 0;
		for(int i = 0; i < n; i++) {
			ja = false;
			jb = false;
				if(s[i].substring(0,1).equals("B") ) {
					ca ++;
					ja = true;
				}
				if(s[i].substring(s[i].length() - 1,s[i].length()).equals("A")) {
					cb ++;
					jb = true;
				}
				if(ja && jb) {
					cc ++;
				}
			}
		ans += Math.min(ca, cb);
		if(cc == cb && cc >= 2) {
			ans --;
		}
		System.out.println(ans);
		sc.close();
	}

}