#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long f = 1, x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + (s - '0');
    s = getchar();
  }
  return x * f;
}
const int jzm = 998244353;
inline int ABS(int x) { return x < 0 ? -x : x; }
int n, m, i, j, s, o, k;
int a[505];
int dp[505][505];
int pos[505][505];
int DP(int l, int r) {
  if (l > r) return 1;
  if (dp[l][r] != -1) return dp[l][r];
  int p = pos[l][r];
  int ls = 0, rs = 0;
  for (int i = l; i <= p; i++) {
    ls = (ls + 0ll + DP(l, i - 1) * 1ll * DP(i, p - 1) % jzm) % jzm;
  }
  for (int i = p; i <= r; i++) {
    rs = (rs + 0ll + DP(p + 1, i) * 1ll * DP(i + 1, r) % jzm) % jzm;
  }
  dp[l][r] = ls * 1ll * rs % jzm;
  return dp[l][r];
}
int main() {
  memset(dp, -1, sizeof(dp));
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    pos[i][i] = i;
    int minn = a[i];
    for (int j = i - 1; j > 0; j--) {
      if (a[j] < minn) {
        minn = a[j];
        pos[j][i] = j;
      } else
        pos[j][i] = pos[j + 1][i];
    }
  }
  printf("%d\n", DP(1, n));
  return 0;
}
