#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353LL;
const int MAXN = 505;
int n, m, a[MAXN], nex[MAXN][MAXN];
long long ans[MAXN][MAXN];
bool found[MAXN][MAXN];
long long dp(int l, int r) {
  if (r - l <= 0) return 1LL;
  if (found[l][r]) return ans[l][r];
  found[l][r] = true;
  long long ansL = 0, ansR = 0;
  for (int i = l; i <= nex[l][r]; ++i) {
    ansL = (ansL + ((dp(l, i - 1) * dp(i, nex[l][r] - 1)) % MOD)) % MOD;
  }
  for (int i = nex[l][r]; i <= r; ++i) {
    ansR = (ansR + ((dp(nex[l][r] + 1, i) * dp(i + 1, r)) % MOD)) % MOD;
  }
  return ans[l][r] = (ansL * ansR) % MOD;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      nex[i][j] = i;
      for (int k = i + 1; k <= j; ++k) {
        if (a[nex[i][j]] > a[k]) nex[i][j] = k;
      }
    }
  }
  printf("%lld\n", dp(0, n - 1));
}
