#include <bits/stdc++.h>
using namespace std;
const int maxN = 510 + 10, mod = 998244353;
int dp[maxN][maxN], c[maxN];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> c[i];
  for (int i = 0; i < n; i++) dp[i][i + 1] = 1;
  for (int i = 0; i <= n; i++) dp[i][i] = 1;
  for (int len = 2; len <= n; len++)
    for (int l = 0; l + len <= n; l++) {
      int r = l + len;
      int mn = n + 1, p = -1;
      for (int j = l; j < r; j++)
        if (c[j] < mn) mn = c[j], p = j;
      long long w1 = 0, w2 = 0;
      for (int j = p; j >= l; j--)
        w1 += 1LL * dp[j][p] * dp[l][j] % mod, w1 %= mod;
      for (int j = p; j < r; j++)
        w2 += 1LL * dp[p + 1][j + 1] * dp[j + 1][r] % mod, w2 %= mod;
      dp[l][r] = 1LL * w1 * w2 % mod;
    }
  cout << dp[0][n] << endl;
}
