#include <bits/stdc++.h>
using namespace std;
const long long N = 5e2 + 10, mod = 998244353;
long long n, m, ar[N], dp[N][N];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (long long i = 0; i < n; i++) cin >> ar[i];
  for (long long i = 0; i <= n; i++) dp[i][i] = dp[i][i + 1] = 1;
  for (long long len = 2; len <= n; len++)
    for (long long l = 0; l <= n - len; l++) {
      long long r = l + len, mn = N, indx = l;
      for (long long i = l; i < r; i++)
        if (ar[i] < mn) mn = ar[i], indx = i;
      long long sum1 = 0, sum2 = 0;
      for (long long i = l; i <= indx; i++)
        sum1 = (sum1 + dp[l][i] * dp[i][indx] % mod) % mod;
      for (long long i = indx + 1; i <= r; i++)
        sum2 = (sum2 + dp[indx + 1][i] * dp[i][r] % mod) % mod;
      dp[l][r] = (dp[l][r] + sum1 * sum2 % mod) % mod;
    }
  cout << dp[0][n] << endl;
}
