#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 998244353;
int n, m;
int c[502];
long long int dp[502][502];
long long int solve(int l, int r) {
  if (l > r) return 1;
  if (dp[l][r]) return dp[l][r];
  if (l == r) return dp[l][r] = 1;
  int k = l;
  for (int i = l; i <= r; i++)
    if (c[i] < c[k]) k = i;
  long long int s1 = 0, s2 = 0;
  for (int i = l; i <= k; i++) (s1 += solve(l, i - 1) * solve(i, k - 1)) %= MOD;
  for (int i = k; i <= r; i++) (s2 += solve(k + 1, i) * solve(i + 1, r)) %= MOD;
  return dp[l][r] = s1 * s2 % MOD;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> c[i];
  cout << solve(0, n - 1) << endl;
  return 0;
}
