using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var m = NN; if (m == 0 || n < m) { WriteLine(0); return; } var dp = new long[m + 1]; if (n == 0) dp[0] = 1; for (var i = 1; i < dp.Length; ++i) { var sum = 1L; for (var j = 0; j < n; ++j) sum *= i; for (var j = 1; j <= i; ++j) { sum -= dp[j] * NCR(i, j); } dp[i] = sum; } WriteLine(dp[m]); } static long NCR(int n, int r) { var ans = 1L; for (var i = n - r; i < n; ++i) ans *= i + 1; for (var i = 0; i < r; ++i) ans /= i + 1; return ans; } }