A permutation *p* of size *n* is an array such that every integer from 1 to *n* occurs exactly once in this array.

Let's call a permutation an almost identity permutation iff there exist at least *n* - *k* indices *i* (1 ≤ *i* ≤ *n*) such that *p*<sub class="lower-index">*i*</sub> = *i*.

Your task is to count the number of almost identity permutations for given numbers *n* and *k*.
The first line contains two integers *n* and *k* (4 ≤ *n* ≤ 1000, 1 ≤ *k* ≤ 4).
none
4 1
1
4 2
7
5 3
31
5 4
76
200 1
1
200 2
19901
200 3
2646701
200 4
584811251
400 1
1
400 2
79801
400 3
21253401
400 4
9477912501
600 1
1
600 2
179701
600 3
71820101
600 4
48187303751
800 1
1
800 2
319601
800 3
170346801
800 4
152620985001
1000 1
1
1000 2
499501
1000 3
332833501
1000 4
373086956251
4 4
24
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from functools import reduce

_ = '''
 (1) Let's define function f(n, k) - exactly k permutation elements
     on non identical indices.
     Our result function is then: F(n, k) = sum(f(n, ki) ki = 0 .. k)
 
 (2) f(n, 0) = 1
     f(n, 1) = 0
 
 (3) We choose k indices - C(n, k).
     All other indices are fixed and identical.
     We need to permutate k! elements
     so we do not set them to their own identical positions.
     Let's define the latter function as ni(k)
 
 (4) ni(0) = 1
     ni(1) = 0
     ni(2) = 1
     ni(3) = 2
     0 1 2 - doesn't count
     0 2 1 - doesn't count
     1 0 2 - doesn't count
     1 2 0
     2 0 1
     2 1 0 - doesn't count
 
 (5) We choose (k-1) elements for first position.
     Let's define chosen element c1
     Then we go to c1 position. There we can choose from (k-1) elements (c2).
     Then we go to c2 position. There we can choose from (k-2) elements (c3).
     Then we go to c3 position. There we can choose from (k-3) elements (c4).
     ni'(k) := (k-1)*(k-1)!
 
     ni'(2) := (2-1)*(2-1)! = 1
     ni'(3) := (3-1)*(3-1)! = 4 - WRONG
 
 Let's just brutforce h(n, k) or manually check the last k=4 answer.
'''
ni = [1, 0, 1, 2, 9]

n, k = map(int, input().split())

def f_exactly_k(n, k):
    return (
            reduce(lambda x, y: x*y, range(n-k+1, n+1), 1) \
            // reduce(lambda x, y: x*y, range(1, k+1), 1)
        ) * ni[k]

s = 0
for ki in range(k+1):
    s += f_exactly_k(n, ki)
print(s)