#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int N = 505;
int c[N], dp[N][N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << setprecision(32);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
    dp[i][i] = 1;
  }
  for (int len = 2; len <= n; len++) {
    for (int l = 1, r = len; r <= n; l++, r++) {
      int m = l;
      for (int i = l; i <= r; i++) {
        if (c[i] < c[m]) m = i;
      }
      long long tmp1, tmp2;
      {
        if (l == m) {
          tmp1 = 1;
        } else {
          tmp1 = dp[l][m - 1] << 1;
          if (tmp1 >= mod) tmp1 -= mod;
          for (int i = l; i < m - 1; i++) {
            tmp1 += dp[l][i] * 1LL * dp[i + 1][m - 1] % mod;
            if (tmp1 >= mod) tmp1 -= mod;
          }
        }
      }
      {
        if (m == r) {
          tmp2 = 1;
        } else {
          tmp2 = dp[m + 1][r] << 1;
          if (tmp2 >= mod) tmp2 -= mod;
          for (int i = m + 1; i < r; i++) {
            tmp2 += dp[m + 1][i] * 1LL * dp[i + 1][r] % mod;
            if (tmp2 >= mod) tmp2 -= mod;
          }
        }
      }
      dp[l][r] = tmp1 * tmp2 % mod;
    }
  }
  cout << dp[1][n] << endl;
  return 0;
}
