#include <bits/stdc++.h>
using namespace std;
const int N = 260, mo = 777777777;
int n, k, ans, c[N * 2][N * 2], f[25][N][N];
int power(int x, int y) {
  int s = 1;
  for (; y; y /= 2, x = 1ll * x * x % mo)
    if (y & 1) s = 1ll * s * x % mo;
  return s;
}
int main() {
  scanf("%d%d", &n, &k);
  k = n - k;
  for (int i = 0; i <= n; i++) {
    c[i][0] = 1;
    for (int j = 1; j <= i; j++) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mo;
  }
  f[0][0][0] = 1;
  for (int i = 1; i <= max(k, n - k); i++)
    for (int v = 23; v >= 0; v--)
      for (int v1 = k; v1 >= 0; v1--)
        for (int v2 = (v1 <= k - i ? n - k : n - k - i); v2 >= 0; v2--) {
          int tmp = 1ll * f[v][v1][v2] * c[v1 + v2 + i][i] % mo;
          if (v1 + i <= k)
            (((f[v + 1][v1 + i][v2]) += (tmp)) >= mo
                 ? f[v + 1][v1 + i][v2] -= mo
                 : 233);
          ;
          if (v2 + i <= n - k)
            (((f[v + 1][v1][v2 + i]) += (mo - tmp)) >= mo
                 ? f[v + 1][v1][v2 + i] -= mo
                 : 233);
          ;
        }
  for (int v = 0; v <= min(n, 23); v++)
    for (int v2 = 0; v2 <= n - k; v2++)
      (((ans) += (1ll * f[v][k][v2] * power(n - v, n - k - v2) % mo *
                  c[n][n - k - v2] % mo)) >= mo
           ? ans -= mo
           : 233);
  ;
  printf("%d\n", ans);
}
