#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 501;
const long long MOD = 998244353;
long long n, m;
long long a[MAXN];
long long dp[MAXN][MAXN];
long long solve(long long L, long long R) {
  if (L >= R) {
    return 1;
  }
  if (dp[L][R] == -1) {
    long long mni = L;
    for (long long i = L; i <= R; i++) {
      if (a[i] < a[mni]) {
        mni = i;
      }
    }
    long long lres = 0;
    for (long long i = L; i <= mni; i++) {
      lres += solve(i, mni - 1) * solve(L, i - 1) % MOD;
      lres %= MOD;
    }
    long long rres = 0;
    for (long long i = R; i >= mni; i--) {
      rres += solve(mni + 1, i) * solve(i + 1, R) % MOD;
      rres %= MOD;
    }
    dp[L][R] = lres * rres % MOD;
  }
  return dp[L][R];
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < MAXN; i++) {
    for (long long j = 0; j < MAXN; j++) {
      dp[i][j] = -1;
    }
  }
  cout << solve(0, n - 1);
  return 0;
}
