#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, m;
  while (~scanf("%d:%d", &h, &m)) {
    int t = 0, tp;
    while (1) {
      tp = (h % 10) * 10 + h / 10;
      if (tp == m) break;
      m++;
      if (m >= 60) {
        h += m / 60;
        m = m % 60;
      }
      h %= 24;
      t++;
    }
    printf("%d\n", t);
  }
  return 0;
}
