#include <bits/stdc++.h>
using namespace std;
long long a[505];
long long mod = 998244353;
long long dp[505][505];
long long get_ans(long long l, long long r) {
  if (dp[l][r]) return dp[l][r];
  if (l >= r) return 1;
  long long pl = l, _min = 1e9;
  for (long long i = l; i <= r; i++) {
    if (a[i] < _min) {
      _min = a[i];
      pl = i;
    }
  }
  long long Ans1 = 0, Ans2 = 0;
  for (long long i = pl; i >= l; i--) {
    Ans1 = (Ans1 + get_ans(l, i - 1) * get_ans(i, pl - 1) % mod) % mod;
  }
  for (long long j = pl; j <= r; j++) {
    Ans2 = (Ans2 + get_ans(pl + 1, j) % mod * get_ans(j + 1, r) % mod) % mod;
  }
  return dp[l][r] = (Ans1 * Ans2) % mod;
}
signed main() {
  long long n, m;
  scanf("%lld %lld", &n, &m);
  for (long long i = 1; i <= m; i++) scanf("%lld", &a[i]);
  printf("%lld", get_ans(1, n));
  return 0;
}
