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 (n == 0) { WriteLine("NaN"); return; } if (m == 0 || n < m) { WriteLine(0); return; } var dp = new long[m + 1]; for (var i = 1; i < dp.Length; ++i) { var sum = (long)Math.Pow(i, n); 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; } }