Problem:
Max Score: $250$ Points

Problem Statement

Snuke has a very long calendar. It has a grid with $n$ rows and $7$ columns. One day, he noticed that calendar has a following regularity.

The cell at the $i$-th row and $j$-th column contains the integer $7i+j-7$.

A good sub-grid is a $3 \times 3$ sub-grid and the sum of integers in this sub-grid mod $11$ is $k$.

How many good sub-grid are there? Write a program and help him.

Input

The input is given from standard input in the following format.

$n \quad k$

Output

Print the number of good sub-grid. If there are no solution exists, print 0.

Constraints

$1 \le n \le 10^9$

$0 \le k \le 10$

Subtasks

Subtask 1 [ $150$ points ]

The testcase in the subtask satisfies $1 \le n \le 100$.

Subtask 2 [ $100$ points ]

There are no additional constraints.

Sample Input 1

7 7

Sample Output 1

2

In this case, the calendar likes this matrix.

Sun.

Mon.

Tue.

Wed.

Thu.

Fri.

Sat.

Week 1

1

2

3

4

5

6

7

Week 2

8

9

10

11

12

13

14

Week 3

15

16

17

18

19

20

21

Week 4

22

23

24

25

26

27

28

Week 5

29

30

31

32

33

34

35

Week 6

36

37

38

39

40

41

42

Week 7

43

44

45

46

47

48

49

The cell at $i$-th row and $j$-th column is denoted $(i, j)$.

If upper-left is $(1, 5)$, the sum of integers is $5+6+7+12+13+14+19+20+21=117$.

If upper-left is $(3, 2)$, the sum of integers is $16+17+18+23+24+25+30+31+32=216$.

Therefore, there are 2 good sub-grids.

Sample Input 2

6 0

Sample Output 2

2

If upper-left is $(1, 3)$ or $(4, 4)$, it is a good sub-grid.

Sample Input 3

18 10

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Wrong Answer)

import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) throws Exception{	
		FastScanner sc = new FastScanner();
		int i, j;
			//code
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		int[] a = new int[5];
		int[] b = new int[5];
		
		
		if(n <= 2){
			pl(0);
			return;
		}
	
		int c=0;
		
		for(i=1; i<=5; i++){
			a[i-1] = (9+i*9)%11;
		}
		
		if(n <= 11){
			for(i=1; i<=n-2; i++){
				for(j=0; j<5; j++){
					a[j] = (a[j]+8)%11;
					if(a[j] == k)c++;
				}
			}
		pl(c);
		}else{
			for(i=1; i<=n-2; i++){
				for(j=0; j<5; j++){
					a[j] = (a[j]+8)%11;
					if(a[j] == k){
						if(b[j] == 0){
							b[j] = i;
							c++;
						}
					}
				}
			}
			
			for(i=0; i<5; i++){
				c += (n-b[i]) / 11;
			}
			pl(c);
		}
	}
	
	
	
	static void func(){

	}
	
	static void p(String s){ System.out.print(s); }
	static void pl(String s){ System.out.println(s); }
	static void p(int s){ System.out.print(s); }
	static void pl(int s){ System.out.println(s); }
	static void p(long s){ System.out.print(s); }
	static void pl(long s){ System.out.println(s); }
	static void p(double s){ System.out.print(s); }
	static void pl(double s){ System.out.println(s); }
	static void p(boolean s){ System.out.print(s); }
	static void pl(boolean s){ System.out.println(s); }
	

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}